Emit trunc nuw for unchecked shifts and to_immediate_scalar

- For shifts this shrinks the IR by no longer needing an `assume` while still providing the UB information
- Having this on the `i8`→`i1` truncations will hopefully help with some places that have to load `i8`s or pass those in LLVM structs without range information
This commit is contained in:
Scott McMurray 2025-02-14 20:25:43 -08:00
parent ed49386d3a
commit 511bf307f0
10 changed files with 77 additions and 50 deletions

View file

@ -1694,7 +1694,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
fn to_immediate_scalar(&mut self, val: Self::Value, scalar: abi::Scalar) -> Self::Value {
if scalar.is_bool() {
return self.trunc(val, self.cx().type_i1());
return self.unchecked_utrunc(val, self.cx().type_i1());
}
val
}