[PATCH] D40480: MemorySSA backed Dead Store Elimination.

David Green via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 03:31:40 PST 2017


Hello

I think see what you are saying. That we can use the aa from SILoc -> Current to tell us about SILoc -> Use. Something like this, though:

define i32 @test(i32* %P, i32 %y) {
; 1 = MemoryDef(liveOnEntry)
  store i32 1, i32* %P
  %Py = getelementptr i32, i32* %P, i32 %y
; 2 = MemoryDef(1)
  store i32 2, i32* %Py
  %P1 = getelementptr i32, i32* %P, i32 1
; MemoryUse(2)
  %l = load i32, i32* %P1
; 3 = MemoryDef(2)
  store i32 3, i32* %P
  ret i32 %l
}

Store 1 is dead by store 3, even though there is a mayalias store2 and a noalias load between. Or am I still misunderstanding you? Changing this to be a may/must alias load would block the DSE. So the mayalias of 2 doesn't tell us enough about the alias of the load.

We are not going for PDSE with this, so will always be far away from optimal, but this would break my "try not to be worse than before" goal. I've found some other cases of this around PartialEarlierWithFullLater, where a Def has a partial overwrite Def and a Use which doesn't dominate the Def.

I feel I must still be misunderstanding you though. If Current==SI then we can skip these checks as they are always false, sounds good, that I like. If SI->Current is NoAlias we can't safely treat SI->Use as noalias though. NoAlias SI->Current + MayAlias Current->Use could be MayAlias in total. We either do the check of SI->Use (as it's likely to be noalias), or always treat any uses as a break (which sounds too pessimistic to me). And if Start->Current is may|must, there are cases we will miss by just treating the Use as may|must (but it might be worth it for compile speed).

define i32 @test(i32* %P, i32 %y) {
; 1 = MemoryDef(liveOnEntry)
  store i32 1, i32* %P
  %P1 = getelementptr i32, i32* %P, i32 1
; 2 = MemoryDef(1)
  store i32 2, i32* %P1
  %Py = getelementptr i32, i32* %P, i32 %y
; MemoryUse(2)
  %l = load i32, i32* %Py
; 3 = MemoryDef(2)
  store i32 3, i32* %P
  ret i32 %l
}

Let me known if I'm getting this wrong
Dave
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


More information about the llvm-commits mailing list