[PATCH] D127595: [DAG] visitINSERT_VECTOR_ELT - attempt to reconstruct BUILD_VECTOR before other fold interfere

Amaury SECHET via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 12 08:43:48 PDT 2022


deadalnix accepted this revision.
deadalnix added a comment.
This revision is now accepted and ready to land.

The test for which this triggers seems overly restrictive, but this is good.



================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:19433
+    // chain.
+    if (Elt == (NumElts - 1)) {
+      SmallVector<SDValue> ReverseInsertions;
----------------
That seems overly restrictive:
 - The remaining elements could be undef - this is a relatively common occurrence, as far as i can tell.
 - The element could be inserted in pretty much any order (unless there is some canonicalization?)


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:19444
+        auto *CurIdx = dyn_cast<ConstantSDNode>(CurVec.getOperand(2));
+        if (!CurIdx || CurIdx->getAPIntValue() != ((NumElts - 1) - I))
+          break;
----------------
this assumes proper order, do we make sure this is cannonical in some way?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127595/new/

https://reviews.llvm.org/D127595



More information about the llvm-commits mailing list