[llvm] r317748 - [X86] Make sure we don't read too many operands from X86ISD::FMADDS1/FMADDS3 nodes when doing FNEG combine.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 8 17:06:48 PST 2017
Author: ctopper
Date: Wed Nov 8 17:06:47 2017
New Revision: 317748
URL: http://llvm.org/viewvc/llvm-project?rev=317748&view=rev
Log:
[X86] Make sure we don't read too many operands from X86ISD::FMADDS1/FMADDS3 nodes when doing FNEG combine.
r317453 added new ISD nodes without rounding modes that were added to an existing if/else chain. But all the previous nodes handled there included a rounding mode. The final code after this if/else chain expected an extra operand that isn't present for the new nodes.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/fma-fneg-combine.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=317748&r1=317747&r2=317748&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Nov 8 17:06:47 2017
@@ -35565,8 +35565,11 @@ static SDValue combineFMA(SDNode *N, Sel
// Only return the node is the opcode was changed or one of the
// operand was negated. If not, we'll just recreate the same node.
- if (HasNeg || NewOpcode != N->getOpcode())
- return DAG.getNode(NewOpcode, dl, VT, A, B, C, N->getOperand(3));
+ if (HasNeg || NewOpcode != N->getOpcode()) {
+ if (N->getNumOperands() == 4)
+ return DAG.getNode(NewOpcode, dl, VT, A, B, C, N->getOperand(3));
+ return DAG.getNode(NewOpcode, dl, VT, A, B, C);
+ }
return SDValue();
}
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=317748&r1=317747&r2=317748&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fma-fneg-combine.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fma-fneg-combine.ll Wed Nov 8 17:06:47 2017
@@ -160,6 +160,28 @@ entry:
declare <4 x float> @llvm.x86.avx512.mask3.vfmadd.ss(<4 x float>, <4 x float>, <4 x float>, i8, i32)
+define <4 x float> @test11b(<4 x float> %a, <4 x float> %b, <4 x float> %c, i8 zeroext %mask) local_unnamed_addr #0 {
+; SKX-LABEL: test11b:
+; SKX: # BB#0: # %entry
+; SKX-NEXT: kmovd %edi, %k1
+; SKX-NEXT: vfmsub213ss %xmm2, %xmm1, %xmm1 {%k1}
+; SKX-NEXT: vmovaps %xmm1, %xmm0
+; SKX-NEXT: retq
+;
+; KNL-LABEL: test11b:
+; KNL: # BB#0: # %entry
+; KNL-NEXT: kmovw %edi, %k1
+; KNL-NEXT: vfmsub213ss %xmm2, %xmm1, %xmm1 {%k1}
+; KNL-NEXT: vmovaps %xmm1, %xmm0
+; KNL-NEXT: retq
+entry:
+ %sub.i = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %c
+ %0 = tail call <4 x float> @llvm.x86.avx512.mask.vfmadd.ss(<4 x float> %b, <4 x float> %b, <4 x float> %sub.i, i8 %mask, i32 4) #10
+ ret <4 x float> %0
+}
+
+declare <4 x float> @llvm.x86.avx512.mask.vfmadd.ss(<4 x float>, <4 x float>, <4 x float>, i8, i32)
+
define <8 x double> @test12(<8 x double> %a, <8 x double> %b, <8 x double> %c, i8 %mask) {
; SKX-LABEL: test12:
; SKX: # BB#0: # %entry
More information about the llvm-commits
mailing list