From bdb1c4c44e9ac7842f84f77432ec1816b47e6b97 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 30 Jul 2019 14:59:04 -0700 Subject: [PATCH] Fix inkwell assertion due to treating vector as float. Fix llvm backend fatal error due to missing support for fminimum/fmaximum. --- lib/llvm-backend/src/code.rs | 12 ++++++------ lib/llvm-backend/src/intrinsics.rs | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index f6b703b1a..df42e8f9a 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -2129,7 +2129,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v2 = builder.build_bitcast(v2, intrinsics.f32x4_ty, ""); let v1 = canonicalize_nans(builder, intrinsics, v1); let v2 = canonicalize_nans(builder, intrinsics, v2); - let (v1, v2) = (v1.into_float_value(), v2.into_float_value()); + let (v1, v2) = (v1.into_vector_value(), v2.into_vector_value()); let res = builder.build_float_add(v1, v2, &state.var_name()); let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); state.push1(res); @@ -2140,7 +2140,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v2 = builder.build_bitcast(v2, intrinsics.f64x2_ty, ""); let v1 = canonicalize_nans(builder, intrinsics, v1); let v2 = canonicalize_nans(builder, intrinsics, v2); - let (v1, v2) = (v1.into_float_value(), v2.into_float_value()); + let (v1, v2) = (v1.into_vector_value(), v2.into_vector_value()); let res = builder.build_float_add(v1, v2, &state.var_name()); let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); state.push1(res); @@ -2159,7 +2159,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v2 = builder.build_bitcast(v2, intrinsics.f32x4_ty, ""); let v1 = canonicalize_nans(builder, intrinsics, v1); let v2 = canonicalize_nans(builder, intrinsics, v2); - let (v1, v2) = (v1.into_float_value(), v2.into_float_value()); + let (v1, v2) = (v1.into_vector_value(), v2.into_vector_value()); let res = builder.build_float_sub(v1, v2, &state.var_name()); let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); state.push1(res); @@ -2170,7 +2170,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v2 = builder.build_bitcast(v2, intrinsics.f64x2_ty, ""); let v1 = canonicalize_nans(builder, intrinsics, v1); let v2 = canonicalize_nans(builder, intrinsics, v2); - let (v1, v2) = (v1.into_float_value(), v2.into_float_value()); + let (v1, v2) = (v1.into_vector_value(), v2.into_vector_value()); let res = builder.build_float_sub(v1, v2, &state.var_name()); let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); state.push1(res); @@ -2219,7 +2219,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v2 = builder.build_bitcast(v2, intrinsics.f32x4_ty, ""); let v1 = canonicalize_nans(builder, intrinsics, v1); let v2 = canonicalize_nans(builder, intrinsics, v2); - let (v1, v2) = (v1.into_float_value(), v2.into_float_value()); + let (v1, v2) = (v1.into_vector_value(), v2.into_vector_value()); let res = builder.build_float_div(v1, v2, &state.var_name()); let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); state.push1(res); @@ -2230,7 +2230,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let v2 = builder.build_bitcast(v2, intrinsics.f64x2_ty, ""); let v1 = canonicalize_nans(builder, intrinsics, v1); let v2 = canonicalize_nans(builder, intrinsics, v2); - let (v1, v2) = (v1.into_float_value(), v2.into_float_value()); + let (v1, v2) = (v1.into_vector_value(), v2.into_vector_value()); let res = builder.build_float_div(v1, v2, &state.var_name()); let res = builder.build_bitcast(res, intrinsics.i128_ty, ""); state.push1(res); diff --git a/lib/llvm-backend/src/intrinsics.rs b/lib/llvm-backend/src/intrinsics.rs index 7ea57ae08..210fb15e6 100644 --- a/lib/llvm-backend/src/intrinsics.rs +++ b/lib/llvm-backend/src/intrinsics.rs @@ -328,12 +328,12 @@ impl Intrinsics { minimum_f32: module.add_function("llvm.minnum.f32", ret_f32_take_f32_f32, None), minimum_f64: module.add_function("llvm.minnum.f64", ret_f64_take_f64_f64, None), minimum_f32x4: module.add_function( - "llvm.minimum.v4f32", + "llvm.minnum.v4f32", ret_f32x4_take_f32x4_f32x4, None, ), minimum_f64x2: module.add_function( - "llvm.minimum.v2f64", + "llvm.minnum.v2f64", ret_f64x2_take_f64x2_f64x2, None, ), @@ -341,12 +341,12 @@ impl Intrinsics { maximum_f32: module.add_function("llvm.maxnum.f32", ret_f32_take_f32_f32, None), maximum_f64: module.add_function("llvm.maxnum.f64", ret_f64_take_f64_f64, None), maximum_f32x4: module.add_function( - "llvm.maximum.v4f32", + "llvm.maxnum.v4f32", ret_f32x4_take_f32x4_f32x4, None, ), maximum_f64x2: module.add_function( - "llvm.maximum.v2f64", + "llvm.maxnum.v2f64", ret_f64x2_take_f64x2_f64x2, None, ),