Skip to content

Commit 166fe54

Browse files
committed
Explain side-effects from simplify_operand.
1 parent 22ed51e commit 166fe54

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
@@ -794,6 +794,8 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
794794
let ty = lhs.ty(self.local_decls, self.tcx);
795795
let lhs = self.simplify_operand(lhs, location);
796796
let rhs = self.simplify_operand(rhs, location);
797+
// Only short-circuit options after we called `simplify_operand`
798+
// on both operands for side effect.
797799
let lhs = lhs?;
798800
let rhs = rhs?;
799801
if let Some(value) = self.simplify_binary(op, false, ty, lhs, rhs) {
@@ -805,6 +807,8 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
805807
let ty = lhs.ty(self.local_decls, self.tcx);
806808
let lhs = self.simplify_operand(lhs, location);
807809
let rhs = self.simplify_operand(rhs, location);
810+
// Only short-circuit options after we called `simplify_operand`
811+
// on both operands for side effect.
808812
let lhs = lhs?;
809813
let rhs = rhs?;
810814
if let Some(value) = self.simplify_binary(op, true, ty, lhs, rhs) {

0 commit comments

Comments
 (0)