-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do some simple constant propagation in the ConstProp pass #60597
Conversation
This comment has been minimized.
This comment has been minimized.
Feedback resolved |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Do some simple constant propagation in the ConstProp pass r? @oli-obk I added a few test cases. Let me know if you think there should be more.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
r? @eddyb This is a very conservative constant propagator that will only replace the rhs of assignments with constants. Any other avenues for constant propagation are left for future changes. |
This comment has been minimized.
This comment has been minimized.
@oli-obk This is gated on |
It's unlikely that this would cause performance changes of the compiled binary. LLVM should take care of that just fine. I wanted to run perfbot to see whether the const propagation slows down compilation. I assumed our perf test suite runs with full MIR optimizations, but I should have checked. I'll do that now |
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Right. So we can check the perf when we decrease the minimum level where the propagator is turned on or make O2 actually pass all tests |
@bors try |
⌛ Trying commit 9453e59332b5aa41a95d0b3ae9c262e3661aac46 with merge 0a38017c5f0419a3bce64fccf7d926df2ce08476... |
This comment has been minimized.
This comment has been minimized.
// return; | ||
// } | ||
// END rustc.main.ConstProp.before.mir | ||
// START rustc.main.ConstProp.after.mir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mir after const prop doesn't seem to be different from before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. I just added this test to try to "lock in" more of the behavior. I have additional changes to improve the constant propagation code incoming but per @oli-obk's feedback, I wanted to keep this PR small.
ScalarMaybeUndef::Scalar(two) | ||
) => { | ||
let ty = &value.layout.ty.sty; | ||
if let ty::Tuple(substs) = ty { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why this is needed, you should be able to create a ty::Const
from any constant.
The results aren't ideal but they represent the current state.
Pushed fixes |
@bors r+ |
📌 Commit b17066d has been approved by |
⌛ Testing commit b17066d with merge 5b7ec0965850679fc5122e82693401e041c1157e... |
💔 Test failed - status-appveyor |
@bors retry |
Do some simple constant propagation in the ConstProp pass r? @oli-obk I added a few test cases. Let me know if you think there should be more.
Rollup of 5 pull requests Successful merges: - #60207 (Outdent example, preserving nested fence) - #60278 (Document the `html_root_url` doc attribute value.) - #60597 (Do some simple constant propagation in the ConstProp pass) - #60837 (Update release notes for 1.35.0) - #60887 (Update clippy) Failed merges: r? @ghost
r? @oli-obk
I added a few test cases. Let me know if you think there should be more.