[llvm] [DeadStoreElimination] Optimize tautological assignments (PR #75744)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 12 01:52:16 PST 2024


nikic wrote:

> We cannot optimise the store in cases where either of the true/false blocks post dominates the icmp condition. (For reasons similar to not doing so when both blocks are the same.)

Duh, sorry for missing that. What you want to do is replace checks like `StoreBB != BI->getSuccessor(0)` with `!DT.dominates(BasicBlockEdge(BI->getParent(), BI->getSuccessor(0)), StoreBB)`.

> @nikic What are your thoughts on the optimisation happening in 1? Is it expected? Any ideas as to why I am unable to reproduce it using the following test case (in noop-stores.ll):

I applied your patch and tried that example, and the store does get (incorrectly) optimized away for me.

https://github.com/llvm/llvm-project/pull/75744


More information about the llvm-commits mailing list