summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2019-04-03 22:15:29 +0000
committerSanjay Patel <spatel@rotateright.com>2019-04-03 22:15:29 +0000
commit61b5e3c6a991e7ddaf5867bd3043e8c45f801054 (patch)
tree425dd5d12ac5e3b497936692d24d63a2b3bfaa26 /llvm/lib
parente51c12430ffe26c5889f41507e11409bd4f58de2 (diff)
downloadbcm5719-llvm-61b5e3c6a991e7ddaf5867bd3043e8c45f801054.tar.gz
bcm5719-llvm-61b5e3c6a991e7ddaf5867bd3043e8c45f801054.zip
[x86] eliminate movddup of horizontal op
This pattern would show up as a regression if we more aggressively convert vector FP ops to scalar ops. There's still a missed optimization for the v4f64 legal case (AVX) because we create that h-op with an undef operand. We should probably just duplicate the operands for that pattern to avoid trouble. llvm-svn: 357642
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index f22e8934fff..84009979ea1 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -32866,8 +32866,10 @@ static SDValue combineShuffleOfConcatUndef(SDNode *N, SelectionDAG &DAG,
/// Eliminate a redundant shuffle of a horizontal math op.
static SDValue foldShuffleOfHorizOp(SDNode *N) {
- if (N->getOpcode() != ISD::VECTOR_SHUFFLE || !N->getOperand(1).isUndef())
- return SDValue();
+ unsigned Opcode = N->getOpcode();
+ if (Opcode != X86ISD::MOVDDUP)
+ if (Opcode != ISD::VECTOR_SHUFFLE || !N->getOperand(1).isUndef())
+ return SDValue();
SDValue HOp = N->getOperand(0);
if (HOp.getOpcode() != X86ISD::HADD && HOp.getOpcode() != X86ISD::FHADD &&
@@ -32885,6 +32887,13 @@ static SDValue foldShuffleOfHorizOp(SDNode *N) {
// When the operands of a horizontal math op are identical, the low half of
// the result is the same as the high half. If the shuffle is also replicating
// low and high halves, we don't need the shuffle.
+ if (Opcode == X86ISD::MOVDDUP) {
+ // movddup (hadd X, X) --> hadd X, X
+ assert((HOp.getValueType() == MVT::v2f64 ||
+ HOp.getValueType() == MVT::v4f64) && "Unexpected type for h-op");
+ return HOp;
+ }
+
// shuffle (hadd X, X), undef, [low half...high half] --> hadd X, X
ArrayRef<int> Mask = cast<ShuffleVectorSDNode>(N)->getMask();
// TODO: Other mask possibilities like {1,1} and {1,0} could be added here,
OpenPOWER on IntegriCloud