[PATCH] D150294: [X86] Invert transforming `(x * (Pow2_Ceil(C1) - (1 << C0))) & C1` -> `(-x << C0) & C1`

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 13 04:19:24 PDT 2023


RKSimon accepted this revision.
RKSimon added a comment.

LGTM with a few minors



================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:50332
+                            /*AllowTruncation*/ false);
+    if (N1C && N01C) {
+      const APInt &MulC = N01C->getAPIntValue();
----------------
There's no strong reason to require N1 to be a splat - you should be able to use matchUnaryPredicate, this is true for N01C as well, but non-uniform shift costs are trickier (even where they're legal).

But all this can be looked at in a followup - maybe add a TODO?


================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:50339
+        SDValue Neg = DAG.getNode(ISD::SUB, dl, VT, DAG.getConstant(0, dl, VT),
+                                  N0->getOperand(0));
+        int32_t MulCLowBitLog = MulCLowBit.exactLogBase2();
----------------
N0.getOperand(0)


================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:50341
+        int32_t MulCLowBitLog = MulCLowBit.exactLogBase2();
+        assert(MulCLowBitLog != -1);
+        SDValue Shift = DAG.getNode(ISD::SHL, dl, VT, Neg,
----------------
assert message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150294



More information about the llvm-commits mailing list