[LLVMdev] Detecting reduction operations

Scott Ricketts sricketts at maxentric.com
Mon Oct 12 17:23:33 PDT 2009


> But things get more challenging when we toss in,
> say, a constant scalar multiply into each iteration. Then the
> dependencies have an intermediate operations between them:
>
> bb:
>        %indvar = phi i64 [ 0, %bb.nph ], [ %indvar.next, %bb ]
>        %sum = phi i32 [ 0, %bb.nph ], [ %3, %bb ]
>        %1 = getelementptr i32* %X, i64 %indvar
>        %2 = load i32* %1, align 4
>        %3 = mul i32 %2, 4
> %3 = add i32 %2, %sum
>        %indvar.next = add i64 %indvar, 1
>        %exitcond = icmp eq i64 %indvar.next, %tmp.
>        br i1 %exitcond, label %bb2, label %bb
>
> 1) %3 has a true dependency on %sum (this is trivial by just looking
> at the operands of the add inst)
> 2) %sum has an anti
>

Whoops, ignore the second example.

Anyway, I clearly need to think this through a bit more. But it might
be helpful to start looking at the dependence analysis stuff that is
available. Memory dependence will not help in general I think because
the arithmetic could be all done in intermediate values.



More information about the llvm-dev mailing list