[LLVMdev] Wrong optimisation (web demo)?

Joachim B Haga cjhaga at student.matnat.uio.no
Sat Feb 26 09:56:25 PST 2005


I came across the LLVM demo (http://llvm.cs.uiuc.edu/demo/index.cgi) 
today. It seems to mis-optimise my test case, calculating the wrong
value. I'm not a LLVM user so it's not a problem for me; just thought
I'd send it your way in case this is a bug.

The following code should return the value 17 (I tested with GCC, to
be sure):

  int main() {
    int i;
    for (i=0; i<10; i++)
      if (i>5) i+=10;
    return i;
  }

But the demo wants to return 7 instead:

  Output from LLVM disassembler

  target endian = little
  target pointersize = 32
  deplibs = [ "c", "crtend" ]

  implementation   ; Functions:

  int %main() {
  loopexit:
	call void %__main( )
	ret int 7
  }

  declare void %__main()


-- 
Joachim.




More information about the llvm-dev mailing list