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

via llvm-commits llvm-commits at lists.llvm.org
Fri May 3 18:00:15 PDT 2024


================
@@ -5122,6 +5149,29 @@ MachineInstr *CombinerHelper::buildUDivUsingMul(MachineInstr &MI) {
     return true;
   };
 
+  if (MI.getFlag(MachineInstr::MIFlag::IsExact)) {
+    // Collect all magic values from the build vector.
+    bool Matched = matchUnaryPredicate(MRI, RHS, BuildExactUDIVPattern);
+    (void)Matched;
+    assert(Matched && "Expected unary predicate match to succeed");
----------------
AtariDreams wrote:

I am just mirroring the sdiv logic but changing what is necessary. 

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


More information about the llvm-commits mailing list