summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-10-11 23:56:56 +0000
committerSanjay Patel <spatel@rotateright.com>2018-10-11 23:56:56 +0000
commit56b6660d2ed92f3d879eac6e49e70e9279aca9da (patch)
treef9c85ee83b530f6fd58cc8f95c2489bc01eaf604 /llvm/lib
parentdf398bd5fe1f318b018ac1280ac264d4098b34e2 (diff)
downloadbcm5719-llvm-56b6660d2ed92f3d879eac6e49e70e9279aca9da.tar.gz
bcm5719-llvm-56b6660d2ed92f3d879eac6e49e70e9279aca9da.zip
[DAGCombiner] rearrange extract_element+bitcast fold; NFC
I want to add another pattern here that includes scalar_to_vector, so this makes that patch smaller. I was hoping to remove the hasOneUse() check because it shouldn't be necessary for common codegen, but an AMDGPU test has a comment suggesting that the extra check makes things better on one of those targets. llvm-svn: 344320
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 16834dc1a26..7ec5fac390b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -15499,13 +15499,15 @@ SDValue DAGCombiner::visitEXTRACT_VECTOR_ELT(SDNode *N) {
// converts.
}
- // extract_vector_elt (v2i32 (bitcast i64:x)), EltTrunc -> i32 (trunc i64:x)
- bool isLE = DAG.getDataLayout().isLittleEndian();
- unsigned EltTrunc = isLE ? 0 : VT.getVectorNumElements() - 1;
- if (ConstEltNo && InVec.getOpcode() == ISD::BITCAST && InVec.hasOneUse() &&
- ConstEltNo->getZExtValue() == EltTrunc && VT.isInteger()) {
+ if (ConstEltNo && InVec.getOpcode() == ISD::BITCAST) {
+ // The vector index of the LSBs of the source depend on the endian-ness.
+ bool IsLE = DAG.getDataLayout().isLittleEndian();
+
+ // extract_elt (v2i32 (bitcast i64:x)), BCTruncElt -> i32 (trunc i64:x)
+ unsigned BCTruncElt = IsLE ? 0 : VT.getVectorNumElements() - 1;
SDValue BCSrc = InVec.getOperand(0);
- if (BCSrc.getValueType().isScalarInteger())
+ if (InVec.hasOneUse() && ConstEltNo->getZExtValue() == BCTruncElt &&
+ VT.isInteger() && BCSrc.getValueType().isScalarInteger())
return DAG.getNode(ISD::TRUNCATE, SDLoc(N), NVT, BCSrc);
}
OpenPOWER on IntegriCloud