[llvm] r336303 - [X86] Remove some of the packed FMA3 intrinsics since we no longer use them in clang.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 4 19:52:54 PDT 2018
Author: ctopper
Date: Wed Jul 4 19:52:54 2018
New Revision: 336303
URL: http://llvm.org/viewvc/llvm-project?rev=336303&view=rev
Log:
[X86] Remove some of the packed FMA3 intrinsics since we no longer use them in clang.
There's a regression in here due to inability to combine fneg inputs of X86ISD::FMSUB/FNMSUB/FNMADD nodes.
More removals to come, but I wanted to stop and fix the regression that showed up in this first.
Modified:
llvm/trunk/include/llvm/IR/IntrinsicsX86.td
llvm/trunk/lib/IR/AutoUpgrade.cpp
llvm/trunk/lib/Target/X86/X86IntrinsicsInfo.h
llvm/trunk/test/CodeGen/X86/avx2-fma-fneg-combine.ll
llvm/trunk/test/CodeGen/X86/fma-fneg-combine.ll
Modified: llvm/trunk/include/llvm/IR/IntrinsicsX86.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/IntrinsicsX86.td?rev=336303&r1=336302&r2=336303&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/IntrinsicsX86.td (original)
+++ llvm/trunk/include/llvm/IR/IntrinsicsX86.td Wed Jul 4 19:52:54 2018
@@ -1919,22 +1919,6 @@ let TargetPrefix = "x86" in { // All in
Intrinsic<[llvm_v2f64_ty],
[llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
[IntrNoMem]>;
- def int_x86_fma_vfmadd_ps : // FIXME: remove this intrinsic.
- Intrinsic<[llvm_v4f32_ty],
- [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
- [IntrNoMem]>;
- def int_x86_fma_vfmadd_pd : // FIXME: remove this intrinsic.
- Intrinsic<[llvm_v2f64_ty],
- [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
- [IntrNoMem]>;
- def int_x86_fma_vfmadd_ps_256 : // FIXME: remove this intrinsic.
- Intrinsic<[llvm_v8f32_ty],
- [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
- [IntrNoMem]>;
- def int_x86_fma_vfmadd_pd_256 : // FIXME: remove this intrinsic.
- Intrinsic<[llvm_v4f64_ty],
- [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
- [IntrNoMem]>;
def int_x86_fma_vfmaddsub_ps : // FIXME: remove this intrinsic.
Intrinsic<[llvm_v4f32_ty],
Modified: llvm/trunk/lib/IR/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AutoUpgrade.cpp?rev=336303&r1=336302&r2=336303&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AutoUpgrade.cpp (original)
+++ llvm/trunk/lib/IR/AutoUpgrade.cpp Wed Jul 4 19:52:54 2018
@@ -74,6 +74,7 @@ static bool ShouldUpgradeX86Intrinsic(Fu
if (Name=="ssse3.pabs.b.128" || // Added in 6.0
Name=="ssse3.pabs.w.128" || // Added in 6.0
Name=="ssse3.pabs.d.128" || // Added in 6.0
+ Name.startswith("fma.vfmadd.p") || // Added in 7.0
Name.startswith("fma.vfmsub.") || // Added in 7.0
Name.startswith("fma.vfmsubadd.") || // Added in 7.0
Name.startswith("fma.vfnmadd.") || // Added in 7.0
@@ -2745,24 +2746,31 @@ void llvm::UpgradeIntrinsicCall(CallInst
Rep = EmitX86Select(Builder, CI->getArgOperand(3), Rep,
CI->getArgOperand(2));
}
- } else if (IsX86 && Name.startswith("fma.vfmsub")) {
+ } else if (IsX86 && (Name.startswith("fma.vfmadd.p") ||
+ Name.startswith("fma.vfmsub.p") ||
+ Name.startswith("fma.vfnmadd.p") ||
+ Name.startswith("fma.vfnmsub.p"))) {
+ bool NegMul = Name[6] == 'n';
+ bool NegAcc = NegMul ? Name[8] == 's' : Name[7] == 's';
+
+ Value *Ops[] = { CI->getArgOperand(0), CI->getArgOperand(1),
+ CI->getArgOperand(2) };
+
+ if (NegMul)
+ Ops[0] = Builder.CreateFNeg(Ops[0]);
+ if (NegAcc)
+ Ops[2] = Builder.CreateFNeg(Ops[2]);
+
+ Rep = Builder.CreateCall(Intrinsic::getDeclaration(CI->getModule(),
+ Intrinsic::fma,
+ CI->getType()), Ops);
+ } else if (IsX86 && (Name.startswith("fma.vfmsub.s") ||
+ Name.startswith("fma.vfmsubadd.p"))) {
// Handle FMSUB and FSUBADD.
unsigned VecWidth = CI->getType()->getPrimitiveSizeInBits();
unsigned EltWidth = CI->getType()->getScalarSizeInBits();
Intrinsic::ID IID;
- if (Name[10] == '.' && Name[11] == 'p') {
- // Packed FMSUB
- if (VecWidth == 128 && EltWidth == 32)
- IID = Intrinsic::x86_fma_vfmadd_ps;
- else if (VecWidth == 128 && EltWidth == 64)
- IID = Intrinsic::x86_fma_vfmadd_pd;
- else if (VecWidth == 256 && EltWidth == 32)
- IID = Intrinsic::x86_fma_vfmadd_ps_256;
- else if (VecWidth == 256 && EltWidth == 64)
- IID = Intrinsic::x86_fma_vfmadd_pd_256;
- else
- llvm_unreachable("Unexpected intrinsic");
- } else if (Name[10] == '.' && Name[11] == 's') {
+ if (Name[10] == '.' && Name[11] == 's') {
// Scalar FMSUB
if (EltWidth == 32)
IID = Intrinsic::x86_fma_vfmadd_ss;
@@ -2787,37 +2795,21 @@ void llvm::UpgradeIntrinsicCall(CallInst
Value *Ops[] = { CI->getArgOperand(0), CI->getArgOperand(1), Arg2 };
Rep = Builder.CreateCall(Intrinsic::getDeclaration(CI->getModule(), IID),
Ops);
- } else if (IsX86 && (Name.startswith("fma.vfnmadd.") ||
- Name.startswith("fma.vfnmsub."))) {
+ } else if (IsX86 && (Name.startswith("fma.vfnmadd.s") ||
+ Name.startswith("fma.vfnmsub.s"))) {
Value *Arg0 = CI->getArgOperand(0);
Value *Arg1 = CI->getArgOperand(1);
Value *Arg2 = CI->getArgOperand(2);
- unsigned VecWidth = CI->getType()->getPrimitiveSizeInBits();
unsigned EltWidth = CI->getType()->getScalarSizeInBits();
+ // Scalar FNMADD/FNMSUB
+ Arg1 = Builder.CreateFNeg(Arg1); // Arg0 is passthru so invert Arg1.
Intrinsic::ID IID;
- if (Name[12] == 'p') {
- // Packed FNMADD/FNSUB
- Arg0 = Builder.CreateFNeg(Arg0);
- if (VecWidth == 128 && EltWidth == 32)
- IID = Intrinsic::x86_fma_vfmadd_ps;
- else if (VecWidth == 128 && EltWidth == 64)
- IID = Intrinsic::x86_fma_vfmadd_pd;
- else if (VecWidth == 256 && EltWidth == 32)
- IID = Intrinsic::x86_fma_vfmadd_ps_256;
- else if (VecWidth == 256 && EltWidth == 64)
- IID = Intrinsic::x86_fma_vfmadd_pd_256;
- else
- llvm_unreachable("Unexpected intrinsic");
- } else {
- // Scalar FNMADD/FNMSUB
- Arg1 = Builder.CreateFNeg(Arg1); // Arg0 is passthru so invert Arg1.
- if (EltWidth == 32)
- IID = Intrinsic::x86_fma_vfmadd_ss;
- else if (EltWidth == 64)
- IID = Intrinsic::x86_fma_vfmadd_sd;
- else
- llvm_unreachable("Unexpected intrinsic");
- }
+ if (EltWidth == 32)
+ IID = Intrinsic::x86_fma_vfmadd_ss;
+ else if (EltWidth == 64)
+ IID = Intrinsic::x86_fma_vfmadd_sd;
+ else
+ llvm_unreachable("Unexpected intrinsic");
// Invert for FNMSUB.
if (Name[8] == 's')
Arg2 = Builder.CreateFNeg(Arg2);
Modified: llvm/trunk/lib/Target/X86/X86IntrinsicsInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86IntrinsicsInfo.h?rev=336303&r1=336302&r2=336303&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86IntrinsicsInfo.h (original)
+++ llvm/trunk/lib/Target/X86/X86IntrinsicsInfo.h Wed Jul 4 19:52:54 2018
@@ -1249,10 +1249,6 @@ static const IntrinsicData IntrinsicsWi
X86_INTRINSIC_DATA(avx512_vpshrd_w_512, INTR_TYPE_3OP_IMM8, X86ISD::VSHRD, 0),
X86_INTRINSIC_DATA(bmi_bextr_32, INTR_TYPE_2OP, X86ISD::BEXTR, 0),
X86_INTRINSIC_DATA(bmi_bextr_64, INTR_TYPE_2OP, X86ISD::BEXTR, 0),
- X86_INTRINSIC_DATA(fma_vfmadd_pd, INTR_TYPE_3OP, ISD::FMA, 0),
- X86_INTRINSIC_DATA(fma_vfmadd_pd_256, INTR_TYPE_3OP, ISD::FMA, 0),
- X86_INTRINSIC_DATA(fma_vfmadd_ps, INTR_TYPE_3OP, ISD::FMA, 0),
- X86_INTRINSIC_DATA(fma_vfmadd_ps_256, INTR_TYPE_3OP, ISD::FMA, 0),
X86_INTRINSIC_DATA(fma_vfmadd_sd, INTR_TYPE_3OP, X86ISD::FMADDS1, 0),
X86_INTRINSIC_DATA(fma_vfmadd_ss, INTR_TYPE_3OP, X86ISD::FMADDS1, 0),
X86_INTRINSIC_DATA(fma_vfmaddsub_pd, INTR_TYPE_3OP, X86ISD::FMADDSUB, 0),
Modified: llvm/trunk/test/CodeGen/X86/avx2-fma-fneg-combine.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avx2-fma-fneg-combine.ll?rev=336303&r1=336302&r2=336303&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/avx2-fma-fneg-combine.ll (original)
+++ llvm/trunk/test/CodeGen/X86/avx2-fma-fneg-combine.ll Wed Jul 4 19:52:54 2018
@@ -65,12 +65,16 @@ declare <4 x float> @llvm.x86.fma.vfnmad
define <8 x float> @test4(<8 x float> %a, <8 x float> %b, <8 x float> %c) {
; X32-LABEL: test4:
; X32: # %bb.0: # %entry
-; X32-NEXT: vfnmadd213ps {{.*#+}} ymm0 = -(ymm1 * ymm0) + ymm2
+; X32-NEXT: vbroadcastss {{.*#+}} ymm3 = [-0,-0,-0,-0,-0,-0,-0,-0]
+; X32-NEXT: vxorps %ymm3, %ymm2, %ymm2
+; X32-NEXT: vfnmsub213ps {{.*#+}} ymm0 = -(ymm1 * ymm0) - ymm2
; X32-NEXT: retl
;
; X64-LABEL: test4:
; X64: # %bb.0: # %entry
-; X64-NEXT: vfnmadd213ps {{.*#+}} ymm0 = -(ymm1 * ymm0) + ymm2
+; X64-NEXT: vbroadcastss {{.*#+}} ymm3 = [-0,-0,-0,-0,-0,-0,-0,-0]
+; X64-NEXT: vxorps %ymm3, %ymm2, %ymm2
+; X64-NEXT: vfnmsub213ps {{.*#+}} ymm0 = -(ymm1 * ymm0) - ymm2
; X64-NEXT: retq
entry:
%0 = tail call <8 x float> @llvm.x86.fma.vfmsub.ps.256(<8 x float> %a, <8 x float> %b, <8 x float> %c) #2
Modified: llvm/trunk/test/CodeGen/X86/fma-fneg-combine.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fma-fneg-combine.ll?rev=336303&r1=336302&r2=336303&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fma-fneg-combine.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fma-fneg-combine.ll Wed Jul 4 19:52:54 2018
@@ -78,10 +78,18 @@ entry:
define <8 x float> @test7(<8 x float> %a, <8 x float> %b, <8 x float> %c) {
-; CHECK-LABEL: test7:
-; CHECK: # %bb.0: # %entry
-; CHECK-NEXT: vfnmadd213ps %ymm2, %ymm1, %ymm0
-; CHECK-NEXT: retq
+; SKX-LABEL: test7:
+; SKX: # %bb.0: # %entry
+; SKX-NEXT: vxorps {{.*}}(%rip){1to8}, %ymm2, %ymm2
+; SKX-NEXT: vfnmsub213ps {{.*#+}} ymm0 = -(ymm1 * ymm0) - ymm2
+; SKX-NEXT: retq
+;
+; KNL-LABEL: test7:
+; KNL: # %bb.0: # %entry
+; KNL-NEXT: vbroadcastss {{.*#+}} ymm3 = [-0,-0,-0,-0,-0,-0,-0,-0]
+; KNL-NEXT: vxorps %ymm3, %ymm2, %ymm2
+; KNL-NEXT: vfnmsub213ps {{.*#+}} ymm0 = -(ymm1 * ymm0) - ymm2
+; KNL-NEXT: retq
entry:
%0 = tail call <8 x float> @llvm.x86.fma.vfmsub.ps.256(<8 x float> %a, <8 x float> %b, <8 x float> %c) #2
%sub.i = fsub <8 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %0
More information about the llvm-commits
mailing list