This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/57829] Wrong constant folding


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

Mikael Pettersson <mikpe at it dot uu.se> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpe at it dot uu.se

--- Comment #1 from Mikael Pettersson <mikpe at it dot uu.se> ---
If I change it to return the computed value of t, I get wrong code for every
single gcc version from 4.9 down to 3.2.3 on both x86_64 and sparc64.  For

    int main (void)
    {
      volatile int k = 1;
      int t = 2 | ( ( k - 1) >> 31 );
      return t;
    }

gcc-4.9 generates

main:
        movl    $1, -4(%rsp)
        movl    -4(%rsp), %eax
        leal    -1(%rax), %eax
        sarl    $31, %eax
        ret

which completely loses all references to the "2 |" part.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]