[PATCH] D147678: [DAGCombiner][AArch64] Use scalar_to_vector to eliminate bitcast
Allen zhong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 5 20:32:16 PDT 2023
Allen created this revision.
Allen added reviewers: dmgreen, david-arm, sdesmalen, nikic, spatel, paulwalker-arm.
Herald added subscribers: StephenFan, pengfei, hiraditya, kristof.beyls.
Herald added a project: All.
Allen requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Fold t3: v2i16 = bitcast i32 + v2i32
v2i32 any_extend t3
into v2i32 = scalar_to_vector i32
Fix https://github.com/llvm/llvm-project/issues/61638
NOTE: Don't touch getPreferredVectorAction like X86 as this will touch
too many test cases.
https://reviews.llvm.org/D147678
Files:
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/sve-fixed-length-int-extends.ll
Index: llvm/test/CodeGen/AArch64/sve-fixed-length-int-extends.ll
===================================================================
--- llvm/test/CodeGen/AArch64/sve-fixed-length-int-extends.ll
+++ llvm/test/CodeGen/AArch64/sve-fixed-length-int-extends.ll
@@ -1043,4 +1043,13 @@
ret void
}
+define <2 x i16> @bitcast_from_int(i32 %word) {
+; CHECK-LABEL: bitcast_from_int:
+; CHECK: // %bb.0:
+; CHECK-NEXT: fmov s0, w0
+; CHECK-NEXT: ret
+ %ret = bitcast i32 %word to <2 x i16>
+ ret <2 x i16> %ret
+}
+
attributes #0 = { nounwind "target-features"="+sve" }
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -18661,6 +18661,20 @@
N->getOperand(0)->getOpcode() == ISD::SETCC)
return performSignExtendSetCCCombine(N, DCI, DAG);
+ if (N->getValueType(0).isFixedLengthVector() &&
+ N->getOpcode() == ISD::ANY_EXTEND &&
+ N->getOperand(0).getOpcode() == ISD::BITCAST) {
+ SDNode *N00 = N->getOperand(0).getOperand(0)->getNode();
+
+ if (N00.getNode()->getValueType(0).isScalarInteger() &&
+ N->getValueType(0).getScalarType() == N00.getNode()->getValueType(0)) {
+ // Use SCALAR_TO_VECTOR for lane zero
+ SDValue Vec =
+ DAG.getNode(ISD::SCALAR_TO_VECTOR, SDLoc(N), N->getValueType(0), N00);
+ return Vec;
+ }
+ }
+
return SDValue();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147678.511261.patch
Type: text/x-patch
Size: 1510 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230406/110b8f6a/attachment.bin>
More information about the llvm-commits
mailing list