[llvm] [CombinerHelper]: Use undef for handling divisors of one (PR #89784)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 24 01:33:30 PDT 2024
================
@@ -5084,23 +5086,28 @@ MachineInstr *CombinerHelper::buildUDivUsingMul(MachineInstr &MI) {
// Magic algorithm doesn't work for division by 1. We need to emit a select
// at the end.
- // TODO: Use undef values for divisor of 1.
- if (!Divisor.isOne()) {
- UnsignedDivisionByConstantInfo magics =
- UnsignedDivisionByConstantInfo::get(Divisor);
-
- Magic = std::move(magics.Magic);
-
- assert(magics.PreShift < Divisor.getBitWidth() &&
- "We shouldn't generate an undefined shift!");
- assert(magics.PostShift < Divisor.getBitWidth() &&
- "We shouldn't generate an undefined shift!");
- assert((!magics.IsAdd || magics.PreShift == 0) && "Unexpected pre-shift");
- PreShift = magics.PreShift;
- PostShift = magics.PostShift;
- SelNPQ = magics.IsAdd;
+ if (Divisor.isOne()) {
+ PreShifts.push_back(MIB.buildUndef(ScalarShiftAmtTy).getReg(0));
----------------
arsenm wrote:
Call buildUndef with the same time one time and reuse the value for each of these
https://github.com/llvm/llvm-project/pull/89784
More information about the llvm-commits
mailing list