[llvm] [CodeGen] Emit more efficient magic numbers for exact udivs (PR #87161)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 15 11:26:02 PDT 2024
================
@@ -5300,6 +5347,15 @@ bool CombinerHelper::matchUDivByConst(MachineInstr &MI) {
if (MF.getFunction().hasMinSize())
return false;
+ if (MI.getFlag(MachineInstr::MIFlag::IsExact)) {
+ return matchUnaryPredicate(
+ MRI, RHS, [](const Constant *C) { return C && !C->isNullValue(); });
+ }
+
+ auto *RHSDef = MRI.getVRegDef(RHS);
+ if (!isConstantOrConstantVector(*RHSDef, MRI))
+ return false;
+
// Don't do this if the types are not going to be legal.
if (LI) {
if (!isLegalOrBeforeLegalizer({TargetOpcode::G_MUL, {DstTy, DstTy}}))
----------------
topperc wrote:
Oh I guess we didn't check them for the equivalent sdiv transform so maybe not?
https://github.com/llvm/llvm-project/pull/87161
More information about the llvm-commits
mailing list