diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2024-01-08 22:44:38 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2024-01-16 22:34:04 +0000 |
| commit | 166fe54eba4b691b9c69b2a3a24e5b82bd9848e3 (patch) | |
| tree | a949530c59fc7ca509c38364c92813b80acbe72f | |
| parent | 22ed51e136c8ad3a07d181b90e7610501ea69816 (diff) | |
| download | rust-166fe54eba4b691b9c69b2a3a24e5b82bd9848e3.tar.gz rust-166fe54eba4b691b9c69b2a3a24e5b82bd9848e3.zip | |
Explain side-effects from simplify_operand.
| -rw-r--r-- | compiler/rustc_mir_transform/src/gvn.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index fc14ea2696f..7a8e3b87b9b 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -794,6 +794,8 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { let ty = lhs.ty(self.local_decls, self.tcx); let lhs = self.simplify_operand(lhs, location); let rhs = self.simplify_operand(rhs, location); + // Only short-circuit options after we called `simplify_operand` + // on both operands for side effect. let lhs = lhs?; let rhs = rhs?; if let Some(value) = self.simplify_binary(op, false, ty, lhs, rhs) { @@ -805,6 +807,8 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { let ty = lhs.ty(self.local_decls, self.tcx); let lhs = self.simplify_operand(lhs, location); let rhs = self.simplify_operand(rhs, location); + // Only short-circuit options after we called `simplify_operand` + // on both operands for side effect. let lhs = lhs?; let rhs = rhs?; if let Some(value) = self.simplify_binary(op, true, ty, lhs, rhs) { |
