Fix float add/mul reduction codegen
The accumulator is now respected for unordered reductions.
This commit is contained in:
parent
8789c9e595
commit
5c95f5fa6b
@ -249,6 +249,10 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
self.const_uint(self.type_i8(), i as u64)
|
||||
}
|
||||
|
||||
fn const_real(&self, t: &'ll Type, val: f64) -> &'ll Value {
|
||||
unsafe { llvm::LLVMConstReal(t, val) }
|
||||
}
|
||||
|
||||
fn const_struct(
|
||||
&self,
|
||||
elts: &[&'ll Value],
|
||||
|
@ -1663,9 +1663,10 @@ fn generic_simd_intrinsic(
|
||||
acc
|
||||
} else {
|
||||
// unordered arithmetic reductions do not:
|
||||
let identity_acc = if $name.contains("mul") { 1.0 } else { 0.0 };
|
||||
match f.bit_width() {
|
||||
32 => bx.const_undef(bx.type_f32()),
|
||||
64 => bx.const_undef(bx.type_f64()),
|
||||
32 => bx.const_real(bx.type_f32(), identity_acc),
|
||||
64 => bx.const_real(bx.type_f64(), identity_acc),
|
||||
v => {
|
||||
return_error!(r#"
|
||||
unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
|
||||
|
@ -715,6 +715,7 @@ extern "C" {
|
||||
// Operations on scalar constants
|
||||
pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
|
||||
pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
|
||||
pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
|
||||
pub fn LLVMConstIntGetZExtValue(ConstantVal: &Value) -> c_ulonglong;
|
||||
pub fn LLVMRustConstInt128Get(ConstantVal: &Value, SExt: bool,
|
||||
high: &mut u64, low: &mut u64) -> bool;
|
||||
|
@ -17,6 +17,7 @@ pub trait ConstMethods<'tcx>: BackendTypes {
|
||||
fn const_u64(&self, i: u64) -> Self::Value;
|
||||
fn const_usize(&self, i: u64) -> Self::Value;
|
||||
fn const_u8(&self, i: u8) -> Self::Value;
|
||||
fn const_real(&self, t: Self::Type, val: f64) -> Self::Value;
|
||||
|
||||
fn const_struct(&self, elts: &[Self::Value], packed: bool) -> Self::Value;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user