Skip to content

Commit 159cdd3

Browse files
committed
Explain side-effects from simplify_operand.
1 parent ff2495a commit 159cdd3

File tree

1 file changed

+4
-0
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+4
-0
lines changed

compiler/rustc_mir_transform/src/gvn.rs

+4
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,8 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
784784
let ty = lhs.ty(self.local_decls, self.tcx);
785785
let lhs = self.simplify_operand(lhs, location);
786786
let rhs = self.simplify_operand(rhs, location);
787+
// Only short-circuit options after we called `simplify_operand`
788+
// on both operands for side effect.
787789
let lhs = lhs?;
788790
let rhs = rhs?;
789791
if let Some(value) = self.simplify_binary(op, false, ty, lhs, rhs) {
@@ -795,6 +797,8 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
795797
let ty = lhs.ty(self.local_decls, self.tcx);
796798
let lhs = self.simplify_operand(lhs, location);
797799
let rhs = self.simplify_operand(rhs, location);
800+
// Only short-circuit options after we called `simplify_operand`
801+
// on both operands for side effect.
798802
let lhs = lhs?;
799803
let rhs = rhs?;
800804
if let Some(value) = self.simplify_binary(op, true, ty, lhs, rhs) {

0 commit comments

Comments
 (0)