It's more aggressive than we need to be, and leads to strange workarounds in other places like call return value inference. Instead, just directly mark an edge viable.
Tests by Florian Hahn.
Paths
| Differential D49408
[SCCP] Don't use markForcedConstant on branch conditions. ClosedPublic Authored by efriedma on Jul 16 2018, 5:10 PM.
Details Summary It's more aggressive than we need to be, and leads to strange workarounds in other places like call return value inference. Instead, just directly mark an edge viable. Tests by Florian Hahn.
Diff Detail
Event TimelineComment Actions I just collected stats with this patch on the test-suite with LTO. The only difference in stats counters across IPSCCP and SCCP is that with this patch, we get 2 more instructions eliminated in SCCP (sccp.NumInstRemoved). Thinking about it, I am not too surprised that the impact of not forcing the condition to false is tiny. IIUC the only benefit would be if our guess (condition false) is actually true and the condition is used somewhere in the else branch. As mentioned in the discussion at D49384, this helps us to avoid obscure bugs caused by back-propagating information to the condition and resolves D49384 and D48327. I think we could come back to actually distinguishing between dead code and an LLVM "undef" value once there is a bigger need, e.g. because IPSCCP became more powerful
efriedma retitled this revision from [SCCP] [WIP] Don't use markForcedConstant on branch conditions. to [SCCP] Don't use markForcedConstant on branch conditions.. Comment ActionsCleaned up, added some tests. Comment Actions LGTM modulo minor. Thanks.
This revision is now accepted and ready to land.Jul 18 2018, 6:29 PM
Comment Actions LGTM, thanks!
Closed by commit rL337507: [SCCP] Don't use markForcedConstant on branch conditions. (authored by efriedma). · Explain WhyJul 19 2018, 4:07 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 156381 llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
llvm/trunk/test/Transforms/SCCP/ipsccp-branch-unresolved-undef.ll
llvm/trunk/test/Transforms/SCCP/ipsccp-phi-one-pred-dead.ll
llvm/trunk/test/Transforms/SCCP/return-zapped.ll
|