summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-12-03 21:57:35 +0000
committerSanjay Patel <spatel@rotateright.com>2018-12-03 21:57:35 +0000
commitd24f63477d5b54bb5e8207e994c197aae3f91295 (patch)
tree2b877466c27baf3b68484989075d5c767c28ba7b /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parentf76884b0d3b96a151d1c631685f9770d45630173 (diff)
downloadbcm5719-llvm-d24f63477d5b54bb5e8207e994c197aae3f91295.tar.gz
bcm5719-llvm-d24f63477d5b54bb5e8207e994c197aae3f91295.zip
[DAGCombiner] narrow truncated vector binops when legal
This is the smallest vector enhancement I could find to D54640. Here, we're allowing narrowing to only legal vector ops because we'll see regressions without that. All of the test diffs are wins from what I can tell. With AVX/AVX512, we can shrink ymm/zmm ops to xmm. x86 vector multiplies are the problem case that we're avoiding due to the patchwork ISA, and it's not clear to me if we can dance around those regressions using TLI hooks or if we need preliminary patches to plug those holes. Differential Revision: https://reviews.llvm.org/D55126 llvm-svn: 348195
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 4adf2405d30..8ae012b3878 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -9758,14 +9758,18 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
case ISD::AND:
case ISD::OR:
case ISD::XOR:
- // TODO: This should allow vector constants/types too.
if (!LegalOperations && N0.hasOneUse() &&
- (isa<ConstantSDNode>(N0.getOperand(0)) ||
- isa<ConstantSDNode>(N0.getOperand(1)))) {
- SDLoc DL(N);
- SDValue NarrowL = DAG.getNode(ISD::TRUNCATE, DL, VT, N0.getOperand(0));
- SDValue NarrowR = DAG.getNode(ISD::TRUNCATE, DL, VT, N0.getOperand(1));
- return DAG.getNode(N0.getOpcode(), DL, VT, NarrowL, NarrowR);
+ (isConstantOrConstantVector(N0.getOperand(0)) ||
+ isConstantOrConstantVector(N0.getOperand(1)))) {
+ // TODO: We already restricted this to pre-legalization, but for vectors
+ // we are extra cautious to not create an unsupported operation.
+ // Target-specific changes are likely needed to avoid regressions here.
+ if (VT.isScalarInteger() || TLI.isOperationLegal(N0.getOpcode(), VT)) {
+ SDLoc DL(N);
+ SDValue NarrowL = DAG.getNode(ISD::TRUNCATE, DL, VT, N0.getOperand(0));
+ SDValue NarrowR = DAG.getNode(ISD::TRUNCATE, DL, VT, N0.getOperand(1));
+ return DAG.getNode(N0.getOpcode(), DL, VT, NarrowL, NarrowR);
+ }
}
}
OpenPOWER on IntegriCloud