[llvm] [CodeGen] Avoid creating instructions dealing with ones if ones aren't involved in the division (PR #99674)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 21 11:13:39 PDT 2024
================
@@ -5320,12 +5327,16 @@ MachineInstr *CombinerHelper::buildUDivUsingMul(MachineInstr &MI) {
Q = MIB.buildAdd(Ty, NPQ, Q).getReg(0);
}
- Q = MIB.buildLShr(Ty, Q, PostShift).getReg(0);
- auto One = MIB.buildConstant(Ty, 1);
- auto IsOne = MIB.buildICmp(
- CmpInst::Predicate::ICMP_EQ,
- Ty.isScalar() ? LLT::scalar(1) : Ty.changeElementSize(1), RHS, One);
- return MIB.buildSelect(Ty, IsOne, LHS, Q);
+ if (hasAOne) {
+ Q = MIB.buildLShr(Ty, Q, PostShift).getReg(0);
----------------
topperc wrote:
If this really removes instructions, you should be able to show that in an MIR test.
https://github.com/llvm/llvm-project/pull/99674
More information about the llvm-commits
mailing list