[LLVMdev] [PATCH] Teaching ScalarEvolution to handle IV=add(zext(trunc(IV)), Step)
Matthew Curtis
mcurtis at codeaurora.org
Fri Dec 21 11:53:46 PST 2012
On 12/21/2012 12:26 PM, Dan Gohman wrote:
> On Thu, Dec 20, 2012 at 8:36 AM, Matthew Curtis <mcurtis at codeaurora.org> wrote:
>> Ok, so I think I've mis-represented what's really happening.
>> Ignore my previous statements concerning %add :)
>>
>> Again, given:
>>
>> 05: for.body: ; preds = %entry,
>> %for.body
>> 06: %j.04 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
>> 07: %result.03 = phi i32 [ 0, %entry ], [ %add, %for.body ]
>> 08: %conv2 = and i32 %result.03, 255
>> 09: %add = add nsw i32 %conv2, 3
>> 10: %inc = add nsw i32 %j.04, 1
>> 11: %cmp = icmp slt i32 %inc, 8000
>> 12: br i1 %cmp, label %for.body, label %for.end
>>
>> LLVM executes the following:
>>
>> 01: createSCEV(%conv2 = and i32 %result.03, 255)
>> 02: calls getSCEV(%result.03)
>> 03: returns (3 + (zext i8 {-3,+,3}<%for.body> to i32))
> The problem is that this is not a correct expression for %result.03.
> It isn't safe to use incorrect expressions in ScalarEvolution even if
> it happens to work out in the case you're looking at.
>
> Dan
Any suggestions on how to construct a correct expression? Or otherwise
teach ScalarEvolution to handle this case?
BTW, just so I understand, the expression for %result.03 is correct for
n > 0, right?
Matthew C.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
More information about the llvm-dev
mailing list