[LLVMdev] alias set collapse and LICM

Sanjoy Das sanjoy at playingwithpointers.com
Fri Jun 12 15:03:19 PDT 2015


>> Ah, so this seems identical to what Sanjoy suggested initially :)
>
> I think he suggested maintaining two partitions, one for Refs and one for Mods. ModRef accesses would be in both partitions. That might also be helpful, but might not be necessary if all the readonly calls are simply removed from the partition.

I was suggesting keeping a separate alias set tracker instance
tracking only mods.  When hoisting a load instruction, you check if
the memory operand of the load instruction aliases anything in this
mod alias set by calling aliasesPointer on each of
the alias sets in the alias set tracker.  If none of the alias sets
alias the pointer you're loading from, then the pointer can be hoisted
to outside the loop.

LICM would still keep the "normal" ASTracker, that tracks everything,
since you'd need to consult that for sinking stores.

This approach still has the theoretical transitive collapse issue: you
could have two mods, A, B, and a load, L, such that "A noalias L"
but "B mayalias L" and "B mayalias A".  The mod alias set in the mod
alias set tracker for A and B would collapse, and you'd have to
conservatively conclude "A mayalias L" even though your alias analysis
can prove that "A noalias L".  But the way LICM uses AST (to hoist
loads out of the loop), I don't think this is a problem -- "B mayalias
L" is sufficient to prevent hoisting L outside the loop so we could not have
done any better.

-- Sanjoy



More information about the llvm-dev mailing list