diff options
| author | bors <bors@rust-lang.org> | 2023-11-20 11:24:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-11-20 11:24:28 +0000 |
| commit | 46ecc10c6951a2a0e52d93fe5d3acae9743e3ab9 (patch) | |
| tree | 3989c4c98f33267bb093b53e3f47867a3a65f43d /compiler/rustc_codegen_ssa/src | |
| parent | 79e961fa728e543e9b4f8b44f6bc2550ea867d4d (diff) | |
| parent | 791ed333fb978d2b2822d4e32f33bed85277b7e2 (diff) | |
| download | rust-46ecc10c6951a2a0e52d93fe5d3acae9743e3ab9.tar.gz rust-46ecc10c6951a2a0e52d93fe5d3acae9743e3ab9.zip | |
Auto merge of #118082 - compiler-errors:rollup-ejsc8yd, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #117828 (Avoid iterating over hashmaps in astconv) - #117832 (interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch) - #117891 (Recover `dyn` and `impl` after `for<...>`) - #117957 (if available use a Child's pidfd for kill/wait) - #117988 (Handle attempts to have multiple `cfg`d tail expressions) - #117994 (Ignore but do not assume region obligations from unifying headers in negative coherence) - #118000 (Make regionck care about placeholders in outlives components) - #118068 (subtree update cg_gcc 2023/11/17) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/base.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 198e5696357..23054975548 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -322,8 +322,13 @@ pub fn cast_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( if lhs_sz < rhs_sz { bx.trunc(rhs, lhs_llty) } else if lhs_sz > rhs_sz { - // FIXME (#1877: If in the future shifting by negative - // values is no longer undefined then this is wrong. + // We zero-extend even if the RHS is signed. So e.g. `(x: i32) << -1i8` will zero-extend the + // RHS to `255i32`. But then we mask the shift amount to be within the size of the LHS + // anyway so the result is `31` as it should be. All the extra bits introduced by zext + // are masked off so their value does not matter. + // FIXME: if we ever support 512bit integers, this will be wrong! For such large integers, + // the extra bits introduced by zext are *not* all masked away any more. + assert!(lhs_sz <= 256); bx.zext(rhs, lhs_llty) } else { rhs |
