[LLVMdev] Misc optimization issue

Aaron Gray angray at beeb.net
Mon Feb 5 08:34:30 PST 2007


This is from 'early JIT tests' thread on comp.lang.misc.

Given :-

int ltst(int x)
{
int i, j;

j=0;
for(i=0; i<x; i++)j++;

return(j);
}

This is from the online LLVM compiler. AND It does not seem to optimize it down !

; ModuleID = '/tmp/webcompile/_24843_0.bc'
target datalayout = "e-p:32:32"
target endian = little
target pointersize = 32
target triple = "i686-pc-linux-gnu"

implementation   ; Functions:

int %ltst(int %x) {
entry:
%x = cast int %x to uint ; <uint> [#uses=1]
%tmp13 = setgt int %x, 0 ; <bool> [#uses=1]
br bool %tmp13, label %bb, label %bb7

bb:                                                 ; preds = %bb, %entry
%indvar = phi uint [ 0, %entry ], [ %indvar.next, %bb ] ; <uint> [#uses=2]
%i.0.0 = cast uint %indvar to int                 ; <int> [#uses=1]
%tmp1 = add int %i.0.0, 1                 ; <int> [#uses=1]
%indvar.next = add uint %indvar, 1            ; <uint> [#uses=2]
%exitcond = seteq uint %indvar.next, %x ; <bool> [#uses=1]
br bool %exitcond, label %bb7, label %bb

bb7:                                                 ; preds = %bb, %entry
%j.0.1 = phi int [ 0, %entry ], [ %tmp1, %bb ] ; <int> [#uses=1]
ret int %j.0.1
}

Aaron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070205/44df46af/attachment.html>


More information about the llvm-dev mailing list