[LLVMbugs] [Bug 5768] New: Invalid codegen for shifts

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sat Dec 12 10:21:59 PST 2009


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

           Summary: Invalid codegen for shifts
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: asl at math.spbu.ru
                CC: llvmbugs at cs.uiuc.edu


Consider the following code:

#include <stdint.h>

uint8_t lshr8(uint8_t a, uint8_t cnt) {
  return a >> cnt;
}

"clang -ccc-host-triple msp430-elf foo.c -O3 -emit-llvm" yields

define zeroext i8 @lshr8(i8 zeroext %a, i8 zeroext %cnt) nounwind readnone {
entry:
  %conv = zext i8 %a to i16
  %conv2 = zext i8 %cnt to i16
  %shr = lshr i16 %conv, %conv2
  %conv3 = trunc i16 %shr to i8
  ret i8 %conv3
}


note that useless ext's / truncs were added. They are not removed by optimizers
(this is another problem)


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