[LLVMbugs] [Bug 5807] New: likely wrong code bug

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Dec 16 09:36:16 PST 2009


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

           Summary: likely wrong code bug
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: regehr at cs.utah.edu
                CC: llvmbugs at cs.uiuc.edu


In the C code below, x is incremented each time foo() is called.  In the LLVM
code it is not.

regehr at john-home:~$ clang -Os llvm-bad-loop.c -S -emit-llvm -o -
; ModuleID = 'llvm-bad-loop.c'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
target triple = "i386-pc-linux-gnu"

@y = common global i32 0, align 4                 ; <i32*> [#uses=1]

define i32 @foo(i32 %x) nounwind readnone optsize {
entry:
  %shr = ashr i32 %x, 7                           ; <i32> [#uses=1]
  ret i32 %shr
}

define i32 @main() noreturn nounwind optsize {
entry:
  br label %while.body

while.body:                                       ; preds = %entry, %while.body
  volatile store i32 undef, i32* @y
  br label %while.body
}
regehr at john-home:~$ cat llvm-bad-loop.c 
int foo (int x)
{
  return x>>7;
}

volatile int y;

int main (void)
{
  unsigned int x;
  while (1) {
    y = foo (x++);
  }
}
regehr at john-home:~$ clang -v
clang version 1.1 (trunk 91411)
Target: i386-pc-linux-gnu
Thread model: posix


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