[llvm] [CodeGen] Emit a more efficient magic number multiplication for exact udivs (PR #87161)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 1 05:34:33 PDT 2024


================
@@ -5168,7 +5219,8 @@ bool CombinerHelper::matchUDivByConst(MachineInstr &MI) {
   Register RHS = MI.getOperand(2).getReg();
   LLT DstTy = MRI.getType(Dst);
   auto *RHSDef = MRI.getVRegDef(RHS);
-  if (!isConstantOrConstantVector(*RHSDef, MRI))
+  if (!MI.getFlag(MachineInstr::MIFlag::IsExact) &&
+      !isConstantOrConstantVector(*RHSDef, MRI))
----------------
AtariDreams wrote:

To match SDIV and because the exact also works for vectors

https://github.com/llvm/llvm-project/pull/87161


More information about the llvm-commits mailing list