[llvm] [AArch64] Improve lowering of truncating build vectors (PR #81960)

David Green via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 17 00:56:50 PST 2024


================
@@ -19096,6 +19148,28 @@ static SDValue performBuildVectorCombine(SDNode *N,
   SDLoc DL(N);
   EVT VT = N->getValueType(0);
 
+  //    BUILD_VECTOR (extract_elt(Assert[S|Z]ext(x)))
+  // => BUILD_VECTOR (extract_elt(x))
+  SmallVector<SDValue, 8> Ops;
+  bool ExtractExtended = false;
+  for (SDValue Extr : N->ops()) {
+    if (Extr.getOpcode() != ISD::EXTRACT_VECTOR_ELT) {
+      ExtractExtended = false;
+      break;
+    }
+    SDValue ExtractBase = Extr.getOperand(0);
+    if (ExtractBase.getOpcode() == ISD::AssertSext ||
+        ExtractBase.getOpcode() == ISD::AssertZext) {
+      ExtractExtended = true;
+      Ops.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL,
----------------
davemgreen wrote:

This loses information, which might not always be a good thing. In general it is better to check something can be transformed, then create nodes if we know it can be. But it may be better to look through AssertSext/AssertZext in the transform as opposed to removing the nodes.

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


More information about the llvm-commits mailing list