[Bug optimization/12941] [tree-ssa] builtin-bitops-1.c miscompilation

rth at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Jan 23 02:19:00 GMT 2004


------- Additional Comments From rth at gcc dot gnu dot org  2004-01-23 02:19 -------
This is not loop, but combine.  Its line of reasoning goes

1)   (2 & (1 << (63 - i))) != 0)
2) = (((2 >> (63 - i)) & 1) != 0)
3) = (((2 >> ~i) & 1) != 0)         # From SHIFT_COUNT_TRUNCATED
4) = ~i == 1                        # Since only 2 >> 1 & 1 != 0
5) = i == -2

Of course, I is never negative; the correct result is I == 62.

Clearly the reasoning in step 4 is flawed if SHIFT_COUNT_TRUNCATED is set.
I've not yet located the exact place in combine that makes this leap...



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rth at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
            Summary|[tree-ssa] loop             |[tree-ssa] builtin-bitops-
                   |miscompilation              |1.c miscompilation


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



More information about the Gcc-bugs mailing list