Do not implement x86 SIMD abs with host integers

This commit is contained in:
Eduardo Sánchez Muñoz 2024-04-27 17:43:39 +02:00
parent b3b1b498b9
commit b26153555f

View File

@ -739,14 +739,20 @@ fn int_abs<'tcx>(
assert_eq!(op_len, dest_len);
let zero = ImmTy::from_int(0, op.layout.field(this, 0));
for i in 0..dest_len {
let op = this.read_scalar(&this.project_index(&op, i)?)?;
let op = this.read_immediate(&this.project_index(&op, i)?)?;
let dest = this.project_index(&dest, i)?;
// Converting to a host "i128" works since the input is always signed.
let res = op.to_int(dest.layout.size)?.unsigned_abs();
let lt_zero = this.wrapping_binary_op(mir::BinOp::Lt, &op, &zero)?;
let res = if lt_zero.to_scalar().to_bool()? {
this.wrapping_unary_op(mir::UnOp::Neg, &op)?
} else {
op
};
this.write_scalar(Scalar::from_uint(res, dest.layout.size), &dest)?;
this.write_immediate(*res, &dest)?;
}
Ok(())