[PATCH] D150230: [GlobalISel] Implement some binary reassociations, G_ADD for now

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 9 15:24:06 PDT 2023


paquette added inline comments.


================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:4490
+
+  std::optional<APInt> C1 =
+      isConstantOrConstantSplatVector(*MRI.getVRegDef(Op01), MRI);
----------------
might as well just return false here if `!C1` to save a level of indentation


================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:4503
+    }
+    if (getTargetLowering().isReassocProfitable(MRI, Op0, Op1)) {
+      // Reassociate: (op (op x, c1), y) -> (op (op x, y), c1)
----------------
maybe pull the `MRI.hasOneNonDBGUse(Op00)` in here and then we don't need the second `if`?


================
Comment at: llvm/test/CodeGen/AArch64/GlobalISel/prelegalizer-combiner-binop-reassoc.mir:4
+
+# Combins: (Opc (Opc X, C1), C2) -> (Opc X, (Opc C1, C2))
+---
----------------



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150230



More information about the llvm-commits mailing list