about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2024-05-15 14:21:39 +0200
committerGitHub <noreply@github.com>2024-05-15 14:21:39 +0200
commit8d38f2fb11d3536639d1aa0d641e60e1f7dfe64e (patch)
tree5165480f4b9a400d480b7866030d59b3815d70a1
parent2659ff3882ea57c680a6bfc6533e95be346ed9ad (diff)
parent0afd50e8524aee0e9f23d4881bc7cac687c23ddf (diff)
downloadrust-8d38f2fb11d3536639d1aa0d641e60e1f7dfe64e.tar.gz
rust-8d38f2fb11d3536639d1aa0d641e60e1f7dfe64e.zip
Rollup merge of #125137 - RalfJung:mir-sh, r=scottmcm
MIR operators: clarify Shl/Shr handling of negative offsets

"made unsigned" was not fully clear (made unsigned how? by using `abs`? no), so let's say "re-interpreted as an unsigned value of the same size" instead.

r? `@scottmcm`
-rw-r--r--compiler/rustc_middle/src/mir/syntax.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs
index 4278ce823d0..e124b478f41 100644
--- a/compiler/rustc_middle/src/mir/syntax.rs
+++ b/compiler/rustc_middle/src/mir/syntax.rs
@@ -1480,13 +1480,17 @@ pub enum BinOp {
     BitOr,
     /// The `<<` operator (shift left)
     ///
-    /// The offset is truncated to the size of the first operand and made unsigned before shifting.
+    /// The offset is (uniquely) determined as follows:
+    /// - it is "equal modulo LHS::BITS" to the RHS
+    /// - it is in the range `0..LHS::BITS`
     Shl,
     /// Like `Shl`, but is UB if the RHS >= LHS::BITS or RHS < 0
     ShlUnchecked,
     /// The `>>` operator (shift right)
     ///
-    /// The offset is truncated to the size of the first operand and made unsigned before shifting.
+    /// The offset is (uniquely) determined as follows:
+    /// - it is "equal modulo LHS::BITS" to the RHS
+    /// - it is in the range `0..LHS::BITS`
     ///
     /// This is an arithmetic shift if the LHS is signed
     /// and a logical shift if the LHS is unsigned.