[PATCH] D130517: [GlobalISel] Add sdiv exact (X, constant) -> mul combine.

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 19:39:05 PDT 2022


aemerson added inline comments.


================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:5022
+  auto *RHSDef = cast<GenericMachineInstr>(getDefIgnoringCopies(RHS, MRI));
+  if (isa<GBuildVector>(RHSDef)) {
+    Shift = MIB.buildBuildVector(ShiftAmtTy, Shifts).getReg(0);
----------------
foad wrote:
> Is this a way of testing whether the divisor is //not// a splat? It seems a bit hacky. If the divisor is a splat then we could have saved some work above by only computing the multiplicative inverse once.
No, it's just checking if it's a vector type. You're right if it's a splat we can do better here.


================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:5026
+  } else {
+    Shift = Shifts[0];
+    Factor = Factors[0];
----------------
foad wrote:
> How does this work? It seems like it would use a scalar shift amount for a vector shift, which is not allowed by MachineVerifier.
As I said this else is actually just handling the scalar case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130517



More information about the llvm-commits mailing list