[LLVMbugs] [Bug 3617] New: llvm-gcc and clang can' t compile negative shift in O3 correctly

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Feb 18 20:15:08 PST 2009


           Summary: llvm-gcc and clang can't compile negative shift in O3
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: miscompilation
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: dodohack at gmail.com
                CC: llvmbugs at cs.uiuc.edu

Created an attachment (id=2580)
 --> (http://llvm.org/bugs/attachment.cgi?id=2580)
c source file

Source Code: shift.c
int func(int x, int y) {
  x = x << y;
  return x;

int main() {
  int a = 120;
  int b = -2;
  printf("%d\n", func(a,b));
compiled with:
[hwalin at earth UnitTests]$ /opt/llvm-svn/obj/Debug/bin/clang -O=3 --emit-llvm
[hwalin at earth UnitTests]$ cat shift.ll
; ModuleID = 'shift.c'
target datalayout =
target triple = "i386-pc-linux-gnu"
@.str = internal constant [4 x i8] c"%d\0A\00"          ; <[4 x i8]*> [#uses=1]

define i32 @func(i32 %x, i32 %y) nounwind readnone {
        %shl = shl i32 %x, %y           ; <i32> [#uses=1]
        ret i32 %shl

define i32 @main(...) nounwind {
        %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr ([4 x i8]*
@.str, i32 0, i32 0), i32 undef)             ; <i32> [#uses=0]
        ret i32 undef

declare i32 @printf(i8* nocapture, ...) nounwind

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