[PATCH] D130862: [LegalizeTypes] Improve splitting for urem/udiv by constant for some constants.

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 12 05:50:31 PDT 2022


arsenm added a comment.

In D130862#3691501 <https://reviews.llvm.org/D130862#3691501>, @hiraditya wrote:

>> a / 5, and a%10 etc.
>
> Is it possible that the processor already does these tricks internally to improve the performance of these operations?





================
Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:7237-7242
+      if (getBooleanContents(HiLoVT) ==
+          TargetLoweringBase::ZeroOrOneBooleanContent)
+        Carry = DAG.getZExtOrTrunc(Carry, dl, HiLoVT);
+      else
+        Carry = DAG.getSelect(dl, HiLoVT, Carry, DAG.getConstant(1, dl, HiLoVT),
+                              DAG.getConstant(0, dl, HiLoVT));
----------------
Can't you just unconditionally use getZExtOrTrunc? the booleancontents would just apply the optimization fold later


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130862



More information about the llvm-commits mailing list