[LLVMdev] alias set collapse and LICM
Daniel Berlin
dberlin at dberlin.org
Mon Apr 27 17:55:22 PDT 2015
> bb: ; preds = %bb, %bb.nph
> ; 3 = MemoryPhi({bb.nph,liveOnEntry},{bb,1})
> %indvar = phi i64 [ 0, %bb.nph ], [ %tmp11, %bb ]
> %scevgep = getelementptr double, double* %G, i64 %indvar
> %tmp9 = add i64 %indvar, 2
> %scevgep10 = getelementptr double, double* %G, i64 %tmp9
> %tmp11 = add i64 %indvar, 1
> %scevgep12 = getelementptr double, double* %G, i64 %tmp11
> ; MemoryUse(liveOnEntry)
> %2 = load double, double* %scevgep12, align 8
> ; MemoryUse(liveOnEntry)
> %3 = load double, double* %scevgep10, align 8
Note that it knows these are both, memory-wise, not clobbered by the
store in the loop, even though the operands are loop variant (and you
could not hoist these loads out of the loop).
Later, GVN will use this fact to prove the equivalence of these two
loads, and use it to PRE load scevgep12 into a phi of(new load in the
header, %3)
> %4 = fadd double %2, %3
> ; MemoryUse(3)
> %5 = load double, double* %scevgep, align 8
^^^^ Note here it's MemoryUse(3) because the PHI dominates it.
MemorySSA, while computing this, walks and hits the store below it (1
= MemoryDef(3)). But that store does not dominate it, so it is not
valid to say MemoryUse(1). Instead, it unwinds to the nearest
dominating thing.
(that is what i meant by we could make this query O(1), because it
computes the info and throws it away)
We later use this to replace load of scevgep with a phi of (new load
in the header, %6)
> %6 = fadd double %4, %5
> ; 1 = MemoryDef(3)
> store double %6, double* %scevgep12, align 8
> %exitcond = icmp eq i64 %tmp11, %tmp8
> br i1 %exitcond, label %return, label %bb
>
> return: ; preds = %bb, %entry
> ; 2 = MemoryPhi({entry,liveOnEntry},{bb,1})
> ret void
> }
>
>>
>> -- Sanjoy
More information about the llvm-dev
mailing list