forked from OSchip/llvm-project
[X86] Implement _builtin_ia32_vfmaddss and _builtin_ia32_vfmaddsd with native IR using llvm.fma intrinsic.
This generates some extra zeroing currently, but we should be able to quickly address that with some isel patterns. llvm-svn: 336417
This commit is contained in:
parent
c60e1807b3
commit
be4c2933a2
|
@ -9134,6 +9134,16 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
|
|||
Value *Res = Builder.CreateCall(FMA, {A, B, C} );
|
||||
return Builder.CreateInsertElement(Ops[0], Res, (uint64_t)0);
|
||||
}
|
||||
case X86::BI__builtin_ia32_vfmaddss:
|
||||
case X86::BI__builtin_ia32_vfmaddsd: {
|
||||
Value *A = Builder.CreateExtractElement(Ops[0], (uint64_t)0);
|
||||
Value *B = Builder.CreateExtractElement(Ops[1], (uint64_t)0);
|
||||
Value *C = Builder.CreateExtractElement(Ops[2], (uint64_t)0);
|
||||
Function *FMA = CGM.getIntrinsic(Intrinsic::fma, A->getType());
|
||||
Value *Res = Builder.CreateCall(FMA, {A, B, C} );
|
||||
Value *Zero = Constant::getNullValue(Ops[0]->getType());
|
||||
return Builder.CreateInsertElement(Zero, Res, (uint64_t)0);
|
||||
}
|
||||
case X86::BI__builtin_ia32_vfmaddps:
|
||||
case X86::BI__builtin_ia32_vfmaddpd:
|
||||
case X86::BI__builtin_ia32_vfmaddps256:
|
||||
|
|
|
@ -17,13 +17,21 @@ __m128d test_mm_macc_pd(__m128d a, __m128d b, __m128d c) {
|
|||
|
||||
__m128 test_mm_macc_ss(__m128 a, __m128 b, __m128 c) {
|
||||
// CHECK-LABEL: test_mm_macc_ss
|
||||
// CHECK: @llvm.x86.fma4.vfmadd.ss
|
||||
// CHECK: extractelement <4 x float> %{{.*}}, i64 0
|
||||
// CHECK: extractelement <4 x float> %{{.*}}, i64 0
|
||||
// CHECK: extractelement <4 x float> %{{.*}}, i64 0
|
||||
// CHECK: call float @llvm.fma.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
|
||||
// CHECK: insertelement <4 x float> zeroinitializer, float %{{.*}}, i64 0
|
||||
return _mm_macc_ss(a, b, c);
|
||||
}
|
||||
|
||||
__m128d test_mm_macc_sd(__m128d a, __m128d b, __m128d c) {
|
||||
// CHECK-LABEL: test_mm_macc_sd
|
||||
// CHECK: @llvm.x86.fma4.vfmadd.sd
|
||||
// CHECK: extractelement <2 x double> %{{.*}}, i64 0
|
||||
// CHECK: extractelement <2 x double> %{{.*}}, i64 0
|
||||
// CHECK: extractelement <2 x double> %{{.*}}, i64 0
|
||||
// CHECK: call double @llvm.fma.f64(double %{{.*}}, double %{{.*}}, double %{{.*}})
|
||||
// CHECK: insertelement <2 x double> zeroinitializer, double %{{.*}}, i64 0
|
||||
return _mm_macc_sd(a, b, c);
|
||||
}
|
||||
|
||||
|
@ -44,14 +52,22 @@ __m128d test_mm_msub_pd(__m128d a, __m128d b, __m128d c) {
|
|||
__m128 test_mm_msub_ss(__m128 a, __m128 b, __m128 c) {
|
||||
// CHECK-LABEL: test_mm_msub_ss
|
||||
// CHECK: [[NEG:%.+]] = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %{{.+}}
|
||||
// CHECK: @llvm.x86.fma4.vfmadd.ss(<4 x float> %{{.+}}, <4 x float> %{{.+}}, <4 x float> [[NEG]])
|
||||
// CHECK: extractelement <4 x float> %{{.*}}, i64 0
|
||||
// CHECK: extractelement <4 x float> %{{.*}}, i64 0
|
||||
// CHECK: [[C:%.+]] = extractelement <4 x float> [[NEG]], i64 0
|
||||
// CHECK: call float @llvm.fma.f32(float %{{.*}}, float %{{.*}}, float [[C]])
|
||||
// CHECK: insertelement <4 x float> zeroinitializer, float %{{.*}}, i64 0
|
||||
return _mm_msub_ss(a, b, c);
|
||||
}
|
||||
|
||||
__m128d test_mm_msub_sd(__m128d a, __m128d b, __m128d c) {
|
||||
// CHECK-LABEL: test_mm_msub_sd
|
||||
// CHECK: [[NEG:%.+]] = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, %{{.+}}
|
||||
// CHECK: @llvm.x86.fma4.vfmadd.sd(<2 x double> %{{.+}}, <2 x double> %{{.+}}, <2 x double> [[NEG]])
|
||||
// CHECK: extractelement <2 x double> %{{.*}}, i64 0
|
||||
// CHECK: extractelement <2 x double> %{{.*}}, i64 0
|
||||
// CHECK: [[C:%.+]] = extractelement <2 x double> [[NEG]], i64 0
|
||||
// CHECK: call double @llvm.fma.f64(double %{{.*}}, double %{{.*}}, double [[C]])
|
||||
// CHECK: insertelement <2 x double> zeroinitializer, double %{{.*}}, i64 0
|
||||
return _mm_msub_sd(a, b, c);
|
||||
}
|
||||
|
||||
|
@ -72,14 +88,22 @@ __m128d test_mm_nmacc_pd(__m128d a, __m128d b, __m128d c) {
|
|||
__m128 test_mm_nmacc_ss(__m128 a, __m128 b, __m128 c) {
|
||||
// CHECK-LABEL: test_mm_nmacc_ss
|
||||
// CHECK: [[NEG:%.+]] = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %{{.+}}
|
||||
// CHECK: @llvm.x86.fma4.vfmadd.ss(<4 x float> [[NEG]], <4 x float> %{{.+}}, <4 x float> %{{.+}})
|
||||
// CHECK: [[A:%.+]] = extractelement <4 x float> [[NEG]], i64 0
|
||||
// CHECK: extractelement <4 x float> %{{.*}}, i64 0
|
||||
// CHECK: extractelement <4 x float> %{{.*}}, i64 0
|
||||
// CHECK: call float @llvm.fma.f32(float [[A]], float %{{.*}}, float %{{.*}})
|
||||
// CHECK: insertelement <4 x float> zeroinitializer, float %{{.*}}, i64 0
|
||||
return _mm_nmacc_ss(a, b, c);
|
||||
}
|
||||
|
||||
__m128d test_mm_nmacc_sd(__m128d a, __m128d b, __m128d c) {
|
||||
// CHECK-LABEL: test_mm_nmacc_sd
|
||||
// CHECK: [[NEG:%.+]] = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, %{{.+}}
|
||||
// CHECK: @llvm.x86.fma4.vfmadd.sd(<2 x double> [[NEG]], <2 x double> %{{.+}}, <2 x double> %{{.+}})
|
||||
// CHECK: [[A:%.+]] = extractelement <2 x double> [[NEG]], i64 0
|
||||
// CHECK: extractelement <2 x double> %{{.*}}, i64 0
|
||||
// CHECK: extractelement <2 x double> %{{.*}}, i64 0
|
||||
// CHECK: call double @llvm.fma.f64(double [[A]], double %{{.*}}, double %{{.*}})
|
||||
// CHECK: insertelement <2 x double> zeroinitializer, double %{{.*}}, i64 0
|
||||
return _mm_nmacc_sd(a, b, c);
|
||||
}
|
||||
|
||||
|
@ -103,7 +127,11 @@ __m128 test_mm_nmsub_ss(__m128 a, __m128 b, __m128 c) {
|
|||
// CHECK-LABEL: test_mm_nmsub_ss
|
||||
// CHECK: [[NEG:%.+]] = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %{{.+}}
|
||||
// CHECK: [[NEG2:%.+]] = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %{{.+}}
|
||||
// CHECK: @llvm.x86.fma4.vfmadd.ss(<4 x float> [[NEG]], <4 x float> %{{.+}}, <4 x float> [[NEG2]])
|
||||
// CHECK: [[A:%.+]] = extractelement <4 x float> [[NEG]], i64 0
|
||||
// CHECK: extractelement <4 x float> %{{.*}}, i64 0
|
||||
// CHECK: [[C:%.+]] = extractelement <4 x float> [[NEG2]], i64 0
|
||||
// CHECK: call float @llvm.fma.f32(float [[A]], float %{{.*}}, float [[C]])
|
||||
// CHECK: insertelement <4 x float> zeroinitializer, float %{{.*}}, i64 0
|
||||
return _mm_nmsub_ss(a, b, c);
|
||||
}
|
||||
|
||||
|
@ -111,7 +139,11 @@ __m128d test_mm_nmsub_sd(__m128d a, __m128d b, __m128d c) {
|
|||
// CHECK-LABEL: test_mm_nmsub_sd
|
||||
// CHECK: [[NEG:%.+]] = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, %{{.+}}
|
||||
// CHECK: [[NEG2:%.+]] = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, %{{.+}}
|
||||
// CHECK: @llvm.x86.fma4.vfmadd.sd(<2 x double> [[NEG]], <2 x double> %{{.+}}, <2 x double> [[NEG2]])
|
||||
// CHECK: [[A:%.+]] = extractelement <2 x double> [[NEG]], i64 0
|
||||
// CHECK: extractelement <2 x double> %{{.*}}, i64 0
|
||||
// CHECK: [[C:%.+]] = extractelement <2 x double> [[NEG2]], i64 0
|
||||
// CHECK: call double @llvm.fma.f64(double [[A]], double %{{.*}}, double [[C]])
|
||||
// CHECK: insertelement <2 x double> zeroinitializer, double %{{.*}}, i64 0
|
||||
return _mm_nmsub_sd(a, b, c);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue