On 10/05/2015 05:22 PM, Richard Sandiford wrote:
Bernd Schmidt <bschm...@redhat.com> writes:
On 10/05/2015 04:47 PM, Richard Sandiford wrote:
@@ -9536,7 +9520,7 @@ fold_builtin_classify (location_t loc, tree fndecl, tree 
arg, int builtin_index)
        {
          r = TREE_REAL_CST (arg);
          if (real_isinf (&r))
-           return real_compare (GT_EXPR, &r, &dconst0)
+           return real_compare (GT_EXPR, &r, &dconst<0> ())
                   ? integer_one_node : integer_minus_one_node;
          else
            return integer_zero_node;

So... are the templates magic enough not to make us create a new
temporary every time this is used?

Yeah, the static variables become comdat objects keyed off the full name
(dconst<...>::value).  They're shared between calls and between TUs.

Hmm. And since you're returning a reference, taking the address works. The whole thing is subtle enough that it deserves a comment. Since this kind of thing is something I don't like about C++ (simple-looking code expanding into non-obvious behaviour) I'm not going to ack this patch, but if someone else wants to, that's fine.

I do believe you still have some code growth since the inline dconst function always expands code that will initialize the constant. IMO that's not desirable.


Bernd

Reply via email to