[llvm] [AArch64] Improve lowering of truncating uzp1 (PR #82457)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 12 06:15:07 PDT 2024


================
@@ -21058,21 +21054,28 @@ static SDValue performUzpCombine(SDNode *N, SelectionDAG &DAG,
   if (ResVT != MVT::v2i32 && ResVT != MVT::v4i16 && ResVT != MVT::v8i8)
     return SDValue();
 
-  auto getSourceOp = [](SDValue Operand) -> SDValue {
-    const unsigned Opcode = Operand.getOpcode();
-    if (Opcode == ISD::TRUNCATE)
-      return Operand->getOperand(0);
-    if (Opcode == ISD::BITCAST &&
-        Operand->getOperand(0).getOpcode() == ISD::TRUNCATE)
-      return Operand->getOperand(0)->getOperand(0);
-    return SDValue();
-  };
+  SDValue SourceOp0 = peekThroughBitcasts(Op0);
+  SDValue SourceOp1 = peekThroughBitcasts(Op1);
 
-  SDValue SourceOp0 = getSourceOp(Op0);
-  SDValue SourceOp1 = getSourceOp(Op1);
+  // truncating uzp1(x, y) -> xtn(concat (x, y))
+  if (SourceOp0.getValueType() == SourceOp1.getValueType()) {
+    EVT Op0Ty = SourceOp0.getValueType();
+    if ((ResVT == MVT::v4i16 && Op0Ty == MVT::v2i32) ||
----------------
david-arm wrote:

OK yeah it's because when creating CONCAT_VECTORS we should be doing `RequiredOpTy.getDoubleNumVectorElementsVT(*DAG.getContext())`. Anyway, I tried out this change myself and makes the code worse for many tests so just ignore me. :)

https://github.com/llvm/llvm-project/pull/82457


More information about the llvm-commits mailing list