I reduced Rust bug 1562192 to this: #![feature(test)] extern crate test; #[inline(never)] fn foo(f: f32) -> i128 { let sign_bit = 1u32 << 31; let significand_bits = 23; let exponent_bias = 127; let a_abs = f.to_bits() & !sign_bit; let exponent = (a_abs >> significand_bits) - exponent_bias; 1i128 << (exponent - significand_bits) } fn main() { let f = test::black_box(0x8000_00 as f32); println!("{:x}", foo(f)); } Compile it optimized with: env RUSTC_BOOTSTRAP=1 rustc -O [file.rs] On s390x, this produces the following IR: ; i128::foo ; Function Attrs: noinline norecurse nounwind readnone uwtable define internal fastcc i128 @_ZN4i1283foo17h5b7dd13bfb54356eE(float %f) unnamed_addr #2 { start: %0 = bitcast float %f to i32 %1 = lshr i32 %0, 23 %2 = add nuw nsw i32 %1, 106 %3 = and i32 %2, 127 %4 = zext i32 %3 to i128 %5 = shl i128 1, %4 ret i128 %5 } Note the "add 106" instead of subtracting exponent_bias and significand_bits, but the "and 127" is supposed to mask that back into range. SystemZTargetLowering::combineSHIFTROT deems that AND useless and removes it. That might be ok for native instructions, but "shl i128" calls __ashlti3, which does require the value to be in range. I have a patch review here: <https://reviews.llvm.org/D50018>, but the first comment says SHL poison makes that transform was wrong even for smaller integers.
Fixed in llvm-toolset-6.0-llvm-6.0.1-3.el7.
Verified with build llvm-toolset-6.0-llvm-6.0.1-5.el7.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2018:3583