[llvm-branch-commits] [llvm-branch] r371178 - Merging r371088 and r371095:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Sep 6 01:17:47 PDT 2019
Author: hans
Date: Fri Sep 6 01:17:47 2019
New Revision: 371178
URL: http://llvm.org/viewvc/llvm-project?rev=371178&view=rev
Log:
Merging r371088 and r371095:
------------------------------------------------------------------------
r371088 | spatel | 2019-09-05 18:58:18 +0200 (Thu, 05 Sep 2019) | 1 line
[x86] add test for horizontal math bug (PR43225); NFC
------------------------------------------------------------------------
------------------------------------------------------------------------
r371095 | spatel | 2019-09-05 19:28:17 +0200 (Thu, 05 Sep 2019) | 3 lines
[x86] fix horizontal math bug exposed by improved demanded elements analysis (PR43225)
https://bugs.llvm.org/show_bug.cgi?id=43225
------------------------------------------------------------------------
Added:
llvm/branches/release_90/test/CodeGen/X86/haddsub-shuf-undef-operand.ll
- copied, changed from r371088, llvm/trunk/test/CodeGen/X86/haddsub-shuf-undef-operand.ll
Modified:
llvm/branches/release_90/ (props changed)
llvm/branches/release_90/lib/Target/X86/X86ISelLowering.cpp
Propchange: llvm/branches/release_90/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 6 01:17:47 2019
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,366431,366447,366481,366487,366527,366570,366660,366868,366925,367019,367030,367062,367084,367124,367215,367292,367304,367306,367314,367340-367341,367394,367396,367398,367403,367412,367417,367429,367580,367662,367750,367753,367846-367847,367898,367941,368004,368164,368230,368300,368315,368324,368477-368478,368517-368519,368554,368572,368873,369011,369026,369084,369095,369097,369168,369199,369310,369426,369443,369886,370036,370176,370204,370271,370355,370404,370426,370430,370720-370721,370753,371048
+/llvm/trunk:155241,366431,366447,366481,366487,366527,366570,366660,366868,366925,367019,367030,367062,367084,367124,367215,367292,367304,367306,367314,367340-367341,367394,367396,367398,367403,367412,367417,367429,367580,367662,367750,367753,367846-367847,367898,367941,368004,368164,368230,368300,368315,368324,368477-368478,368517-368519,368554,368572,368873,369011,369026,369084,369095,369097,369168,369199,369310,369426,369443,369886,370036,370176,370204,370271,370355,370404,370426,370430,370720-370721,370753,371048,371088,371095
Modified: llvm/branches/release_90/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_90/lib/Target/X86/X86ISelLowering.cpp?rev=371178&r1=371177&r2=371178&view=diff
==============================================================================
--- llvm/branches/release_90/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/branches/release_90/lib/Target/X86/X86ISelLowering.cpp Fri Sep 6 01:17:47 2019
@@ -33594,7 +33594,7 @@ static SDValue combineShuffleOfConcatUnd
}
/// Eliminate a redundant shuffle of a horizontal math op.
-static SDValue foldShuffleOfHorizOp(SDNode *N) {
+static SDValue foldShuffleOfHorizOp(SDNode *N, SelectionDAG &DAG) {
unsigned Opcode = N->getOpcode();
if (Opcode != X86ISD::MOVDDUP && Opcode != X86ISD::VBROADCAST)
if (Opcode != ISD::VECTOR_SHUFFLE || !N->getOperand(1).isUndef())
@@ -33625,6 +33625,25 @@ static SDValue foldShuffleOfHorizOp(SDNo
HOp.getOperand(0) != HOp.getOperand(1))
return SDValue();
+ // The shuffle that we are eliminating may have allowed the horizontal op to
+ // have an undemanded (undefined) operand. Duplicate the other (defined)
+ // operand to ensure that the results are defined across all lanes without the
+ // shuffle.
+ auto updateHOp = [](SDValue HorizOp, SelectionDAG &DAG) {
+ SDValue X;
+ if (HorizOp.getOperand(0).isUndef()) {
+ assert(!HorizOp.getOperand(1).isUndef() && "Not expecting foldable h-op");
+ X = HorizOp.getOperand(1);
+ } else if (HorizOp.getOperand(1).isUndef()) {
+ assert(!HorizOp.getOperand(0).isUndef() && "Not expecting foldable h-op");
+ X = HorizOp.getOperand(0);
+ } else {
+ return HorizOp;
+ }
+ return DAG.getNode(HorizOp.getOpcode(), SDLoc(HorizOp),
+ HorizOp.getValueType(), X, X);
+ };
+
// When the operands of a horizontal math op are identical, the low half of
// the result is the same as the high half. If a target shuffle is also
// replicating low and high halves, we don't need the shuffle.
@@ -33635,7 +33654,7 @@ static SDValue foldShuffleOfHorizOp(SDNo
assert((HOp.getValueType() == MVT::v2f64 ||
HOp.getValueType() == MVT::v4f64) && HOp.getValueType() == VT &&
"Unexpected type for h-op");
- return HOp;
+ return updateHOp(HOp, DAG);
}
return SDValue();
}
@@ -33649,14 +33668,14 @@ static SDValue foldShuffleOfHorizOp(SDNo
(isTargetShuffleEquivalent(Mask, {0, 0}) ||
isTargetShuffleEquivalent(Mask, {0, 1, 0, 1}) ||
isTargetShuffleEquivalent(Mask, {0, 1, 2, 3, 0, 1, 2, 3})))
- return HOp;
+ return updateHOp(HOp, DAG);
if (HOp.getValueSizeInBits() == 256 &&
(isTargetShuffleEquivalent(Mask, {0, 0, 2, 2}) ||
isTargetShuffleEquivalent(Mask, {0, 1, 0, 1, 4, 5, 4, 5}) ||
isTargetShuffleEquivalent(
Mask, {0, 1, 2, 3, 0, 1, 2, 3, 8, 9, 10, 11, 8, 9, 10, 11})))
- return HOp;
+ return updateHOp(HOp, DAG);
return SDValue();
}
@@ -33710,7 +33729,7 @@ static SDValue combineShuffle(SDNode *N,
if (SDValue AddSub = combineShuffleToAddSubOrFMAddSub(N, Subtarget, DAG))
return AddSub;
- if (SDValue HAddSub = foldShuffleOfHorizOp(N))
+ if (SDValue HAddSub = foldShuffleOfHorizOp(N, DAG))
return HAddSub;
}
Copied: llvm/branches/release_90/test/CodeGen/X86/haddsub-shuf-undef-operand.ll (from r371088, llvm/trunk/test/CodeGen/X86/haddsub-shuf-undef-operand.ll)
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_90/test/CodeGen/X86/haddsub-shuf-undef-operand.ll?p2=llvm/branches/release_90/test/CodeGen/X86/haddsub-shuf-undef-operand.ll&p1=llvm/trunk/test/CodeGen/X86/haddsub-shuf-undef-operand.ll&r1=371088&r2=371178&rev=371178&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/haddsub-shuf-undef-operand.ll (original)
+++ llvm/branches/release_90/test/CodeGen/X86/haddsub-shuf-undef-operand.ll Fri Sep 6 01:17:47 2019
@@ -1,14 +1,14 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-- -mattr=avx | FileCheck %s
-; FIXME: Eliminating a shuffle means we have to replace an undef operand of a horizontal op.
+; Eliminating a shuffle means we have to replace an undef operand of a horizontal op.
define void @PR43225(<4 x double>* %p0, <4 x double>* %p1, <4 x double> %x, <4 x double> %y, <4 x double> %z) nounwind {
; CHECK-LABEL: PR43225:
; CHECK: # %bb.0:
; CHECK-NEXT: vmovaps (%rdi), %ymm0
-; CHECK-NEXT: vmovapd (%rsi), %ymm0
-; CHECK-NEXT: vhsubpd %ymm0, %ymm2, %ymm0
+; CHECK-NEXT: vmovaps (%rsi), %ymm0
+; CHECK-NEXT: vhsubpd %ymm2, %ymm2, %ymm0
; CHECK-NEXT: vmovapd %ymm0, (%rdi)
; CHECK-NEXT: vzeroupper
; CHECK-NEXT: retq
More information about the llvm-branch-commits
mailing list