[LLVMdev] Wrong optimisation (web demo)?

Chris Lattner sabre at nondot.org
Sat Feb 26 10:57:13 PST 2005


On Sat, 26 Feb 2005, Joachim B Haga wrote:

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

Fixed.  Patch here:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20050221/024295.html

Testcase here:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20050221/024294.html

Thanks!

-Chris

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

-Chris

-- 
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list