[PATCH] D117794: [ISEL] Canonicalise constant splats to RHS.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 20 08:57:53 PST 2022


craig.topper added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:5613
          "Operand is DELETED_NODE!");
   ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1);
   ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N2);
----------------
We could move the dyn_casts below the isCommutative block and fully rely on isConstantIntBuildVectorOrConstantInt inside the if. That would remove the need to swap the N1C/N2C.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:5618
   if (TLI->isCommutativeBinOp(Opcode)) {
-    if (N1C && !N2C) {
-      std::swap(N1C, N2C);
-      std::swap(N1, N2);
-    } else if (N1CFP && !N2CFP) {
-      std::swap(N1CFP, N2CFP);
+    bool IsN1C = N1C || isConstantIntBuildVectorOrConstantInt(N1);
+    bool IsN2C = N2C || isConstantIntBuildVectorOrConstantInt(N2);
----------------
Just to confirm, This will also handle SPLAT_VECTOR despite its name. Right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117794



More information about the llvm-commits mailing list