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.
Differential D49408
[SCCP] Don't use markForcedConstant on branch conditions. efriedma on Jul 16 2018, 5:10 PM. Authored by
Details 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
Comment Actions LGTM modulo minor. Thanks.
Comment Actions LGTM, thanks!
|
markEdgeExecutable also checks if the edge is already known to be feasible. Maybe it's worth changing markEdgeExecutable to return false, when a unfeasible edge is passed?