[llvm-dev] Loop Invariants Detection questions

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 20 10:23:08 PST 2017


On 1/20/2017 4:43 AM, Thomas RUBIANO wrote:
> Thank you again Eli,
>
> I would like to know if it's not better to use DependenceAnalysis to 
> know which instruction depends on others…
> I'm running this pass on a simple example:
>> while.body:                                       ; preds = %while.cond
>   %1 = load i32, i32* %y, align 4 ← I1
>   %2 = load i32, i32* %y, align 4
>   %mul = mul nsw i32 %1, %2 ← I2
>   store i32 %mul, i32* %z, align 4
>   %3 = load i32, i32* %z, align 4
>   call void @use(i32 %3)
>   %4 = load i32, i32* %x, align 4
>   %5 = load i32, i32* %x, align 4
>   %add = add nsw i32 %4, %5
>   store i32 %add, i32* %y, align 4
>   %6 = load i32, i32* %y, align 4
>   call void @use(i32 %6)
>   %7 = load i32, i32* %x2, align 4
>   store i32 %7, i32* %x, align 4
>   %8 = load i32, i32* %x, align 4
>   call void @use(i32 %8)
>   br label %while.cond
>>
> and here, for instance, I'm expecting to have a dependence between
> %1 = load i32, i32* %y, align 4 → I1
> … ↓ …
> %mul = mul nsw i32 %1, %2 → I2
>
> simply because the %mul uses %1 as input.
>
> But when I dump the dependence "depends(I1,I2,true)" I have nothing… null.
> Did I forget something?

DependenceAnalysis computes whether the memory accesses in two 
instructions overlap.  A multiply doesn't access memory, therefore the 
memory accesses don't overlap.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list