This is to address a problem similar to those in D37460 for Scalar PRE. We should not
PRE across an instruction that may not pass execution to its successor unless it is safe
to speculatively execute it.
Details
Diff Detail
Event Timeline
lib/Transforms/Scalar/GVN.cpp | ||
---|---|---|
2214 | Err, wait, sorry, I wasn't reading carefully enough. What are you trying to check for here? I can't see why it matters if "P" has an implicit control flow instruction; we insert the new instruction at the end of the predecessor, so implicit control flow isn't a problem unless the terminator is an invoke. |
lib/Transforms/Scalar/GVN.cpp | ||
---|---|---|
2214 | You're right, I misinterpreted this part. Invoke is also not a problem because if the terminator was an invoke, then we have a critical edge, and we don't PRE across critical edges without splitting them. This check is obsolete, I'll remove it. |
lib/Transforms/Scalar/GVN.cpp | ||
---|---|---|
2214 | It also seems that it's OK to do it if we don't need to insert a new instruction, i.e. when NumWithout == 0. |
- Removed over-restrictive check;
- Allowed PRE across implicit control flow if it only takes to insert a Phi from existing instructons and not create new instructions.
- Added a new test against item 2.
lib/Transforms/Scalar/GVN.cpp | ||
---|---|---|
2261 | "prevent us from that" isn't correct grammar. And you misspelled "implicit". Maybe move the comment inside the if statement? |
Err, wait, sorry, I wasn't reading carefully enough.
What are you trying to check for here? I can't see why it matters if "P" has an implicit control flow instruction; we insert the new instruction at the end of the predecessor, so implicit control flow isn't a problem unless the terminator is an invoke.