[Bug tree-optimization/38789] [4.4 Regression] __builtin_constant_p appears to eveluate to true for non-constant arguments.

pinskia at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Jan 9 21:57:00 GMT 2009



------- Comment #4 from pinskia at gcc dot gnu dot org  2009-01-09 21:56 -------
(In reply to comment #2)
> where the code is duplicated twice and both cases are constant.


Except it is not duplicated in jump threading.  It would have been ok if it did
but it does not ...

Jump threading proved probability of edge 4->5 too small (it is 1528, should be
10000).
  Threaded jump 3 --> 4 to 4
  Threaded jump 2 --> 4 to 4

Pass statistics:
----------------
Jumps threaded: 2


void bar(int v)
{
        unsigned a;
        a = 0;
        if (v == 2)
          a = 1;
        if (__builtin_constant_p(a)) {
                asm volatile ("you lose. %0" : : "ir" (a));
        } else {
                asm volatile ("you win. %0" : : "ir" (a));
        }
}

is another example.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38789



More information about the Gcc-bugs mailing list