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 optimization/12941] [tree-ssa] builtin-bitops-1.c miscompilation


------- 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


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