[llvm] [CodeGenPrepare] Split x/select(cond,y,C) to select(cond,x/y,x/C) (PR #215967)
Le Gia Bao via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 23:03:27 PDT 2026
================
@@ -559,6 +559,151 @@ PreservedAnalyses CodeGenPreparePass::run(Function &F,
return PA;
}
+static bool isDivOrRem(unsigned Opcode) {
+ switch (Opcode) {
+ case Instruction::SDiv:
+ case Instruction::UDiv:
+ case Instruction::SRem:
+ case Instruction::URem:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static bool isCheapConstantDivisor(Value *V, const TargetLowering *TLI,
+ const DataLayout &DL, AttributeList Attr) {
+ auto *C = dyn_cast<Constant>(V);
+ if (!C)
+ return false;
+ Type *ScalarTy = C->getType()->getScalarType();
----------------
L3GiaBao wrote:
That works, and would need isGuaranteedNotToBePoison also.
https://github.com/llvm/llvm-project/pull/215967
More information about the llvm-commits
mailing list