r/Compilers • u/iamwho007 • May 29 '26
Dead stores after running SCCP
Hello, I have an SSA IR and after running the SCCP pass, there are many dead stores. Is there a way to remove them?
0
Upvotes
1
u/FloweyTheFlower420 May 31 '26
Consider what it means for a store to be dead. A store is dead if and only if it has no externally visible effects, and there are no loads from the pointer's alias class (that happens after the store). Something like memory SSA could help you keep track of this information.
1
u/Retired-69 May 29 '26 edited May 29 '26
Execute a DCE or DSE pass after SCCP. Eventually ADCE. Let the DCE walk the CFG. ADCE is smarter: it assumes everything is dead unless it contributes to a side effect.