summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed.bougacha@gmail.com>2015-03-17 03:23:09 +0000
committerAhmed Bougacha <ahmed.bougacha@gmail.com>2015-03-17 03:23:09 +0000
commite0afb1fe6c2facf927321f8f8e13851293df9796 (patch)
tree93406fa6fcc767b9f2b1df045a26471a50bd7f4f /llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
parente33e6c979c0974368d69e9edad35843d4a39fcef (diff)
downloadbcm5719-llvm-e0afb1fe6c2facf927321f8f8e13851293df9796.tar.gz
bcm5719-llvm-e0afb1fe6c2facf927321f8f8e13851293df9796.zip
[AArch64] Use intermediate step for concat_vectors of illegal truncs.
Optimize concat_vectors of truncated vectors, where the intermediate type is illegal, to avoid said illegality, e.g., (v4i16 (concat_vectors (v2i16 (truncate (v2i64))), (v2i16 (truncate (v2i64))))) -> (v4i16 (truncate (v4i32 (concat_vectors (v2i32 (truncate (v2i64))), (v2i32 (truncate (v2i64))))))) This isn't really target-specific, and, as such, would best go in the DAGCombiner. However, ISD::TRUNCATE legality isn't keyed on both input and result type, so we might generate worse code when we don't know better. On AArch64 we know it's fine for v2i64->v4i16 and v4i32->v8i8. rdar://20022387 llvm-svn: 232459
Diffstat (limited to 'llvm/lib/Target/AArch64/AArch64ISelLowering.cpp')
-rw-r--r--llvm/lib/Target/AArch64/AArch64ISelLowering.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 43f443fc400..f1073beb32f 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -7180,6 +7180,37 @@ static SDValue performConcatVectorsCombine(SDNode *N,
EVT VT = N->getValueType(0);
SDValue N0 = N->getOperand(0), N1 = N->getOperand(1);
+ // Optimize concat_vectors of truncated vectors, where the intermediate
+ // type is illegal, to avoid said illegality, e.g.,
+ // (v4i16 (concat_vectors (v2i16 (truncate (v2i64))),
+ // (v2i16 (truncate (v2i64)))))
+ // ->
+ // (v4i16 (truncate (v4i32 (concat_vectors (v2i32 (truncate (v2i64))),
+ // (v2i32 (truncate (v2i64)))))))
+ // This isn't really target-specific, but ISD::TRUNCATE legality isn't keyed
+ // on both input and result type, so we might generate worse code.
+ // On AArch64 we know it's fine for v2i64->v4i16 and v4i32->v8i8.
+ if (N->getNumOperands() == 2 &&
+ N0->getOpcode() == ISD::TRUNCATE &&
+ N1->getOpcode() == ISD::TRUNCATE) {
+ SDValue N00 = N0->getOperand(0);
+ SDValue N10 = N1->getOperand(0);
+ EVT N00VT = N00.getValueType();
+
+ if (N00VT == N10.getValueType() &&
+ (N00VT == MVT::v2i64 || N00VT == MVT::v4i32) &&
+ N00VT.getScalarSizeInBits() == 4 * VT.getScalarSizeInBits()) {
+ MVT MidVT = (N00VT == MVT::v2i64 ? MVT::v2i32 : MVT::v4i16);
+ MVT ConcatMidVT = MVT::getVectorVT(MidVT.getVectorElementType(),
+ MidVT.getVectorNumElements() * 2);
+ return DAG.getNode(
+ ISD::TRUNCATE, dl, VT,
+ DAG.getNode(ISD::CONCAT_VECTORS, dl, ConcatMidVT,
+ DAG.getNode(ISD::TRUNCATE, dl, MidVT, N00),
+ DAG.getNode(ISD::TRUNCATE, dl, MidVT, N10)));
+ }
+ }
+
// Wait 'til after everything is legalized to try this. That way we have
// legal vector types and such.
if (DCI.isBeforeLegalizeOps())
OpenPOWER on IntegriCloud