[LLVMbugs] [Bug 3851] New: misscompilation : INSTCOMBINE ITERATION generating undef ashr

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Mar 20 13:15:27 PDT 2009


http://llvm.org/bugs/show_bug.cgi?id=3851

           Summary: misscompilation : INSTCOMBINE ITERATION generating undef
                    ashr
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Global Analyses
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: castet.matthieu at free.fr
                CC: llvmbugs at cs.uiuc.edu


$ cat mm2.c 
#include <stdint.h>

#define FILTER_SHIFT 15

int foo(int32_t val)
{
        short dst;
        val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;
        dst = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val;
        printf("%x\n", dst);
}
int main()
{
        foo(0xb6a00000);
}


Building with clang, 
at -O0 it generate ffff8000
at -O3 it generate 7fff

It seems to be because of :
INSTCOMBINE ITERATION #0 on foo
IC: Old =       %shr4 = ashr i32 %shr, 31               ; <i32> [#uses=1]
    New =       <badref> = ashr i32 %add, 32            ; <i32> [#uses=0]
[...]
IC: DCE:        %shr48 = lshr i32 undef, 32             ; <i32> [#uses=0]
IC: DCE:        %shr4 = ashr i32 %add, 32               ; <i32> [#uses=0]

where does the "ashr i32 %add, 32" comes from ?


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list