[PATCH] D100812: [DAGCombiner] Allow operand of step_vector to be negative.

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 21 02:56:49 PDT 2021


sdesmalen added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:3547
 
+  // canonicalize (sub X, step_vector(C)) to (add X,  step_vector(-C))
+  if (N1.getOpcode() == ISD::STEP_VECTOR) {
----------------
nit: double space.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:3548
+  // canonicalize (sub X, step_vector(C)) to (add X,  step_vector(-C))
+  if (N1.getOpcode() == ISD::STEP_VECTOR) {
+    SDValue NewStep = DAG.getConstant(-N1.getConstantOperandAPInt(0), DL,
----------------
If there are multiple uses of step_vector(C), then it may be more beneficial to have a single step_vector(C) and use separate add/sub. Can you add a check that N1 has only a single use?


================
Comment at: llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp:1663
+      StepVal.isNonNegative()
+          ? DAG.getZExtOrTrunc(StartOfHi, dl, HiVT.getVectorElementType())
+          : DAG.getSExtOrTrunc(StartOfHi, dl, HiVT.getVectorElementType());
----------------
This can also use getSExtOrTrunc for the non-negative case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100812



More information about the llvm-commits mailing list