[InstCombine] add helper functions for foldICmpWithConstant; NFCI
Besides breaking up a 700 line function to improve readability,
this sinks the 'FIXME: ConstantInt' check into each helper. So
now we can independently break that restriction within any of the
helper functions.
As much as possible, the code was only {cut/paste/clang-format}'ed
to minimize risk (no functional changes intended), so several more
readability improvements are still possible.
llvm-svn: 278828
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index 88c52e2..7ce5ac1 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -548,10 +548,10 @@
ConstantInt *AndCst = nullptr);
Instruction *foldFCmpIntToFPConst(FCmpInst &I, Instruction *LHSI,
Constant *RHSC);
- Instruction *foldICmpDivConst(ICmpInst &ICI, BinaryOperator *DivI,
- ConstantInt *DivRHS);
- Instruction *foldICmpShrConst(ICmpInst &ICI, BinaryOperator *DivI,
- ConstantInt *DivRHS);
+ Instruction *foldICmpDivConstConst(ICmpInst &ICI, BinaryOperator *DivI,
+ ConstantInt *DivRHS);
+ Instruction *foldICmpShrConstConst(ICmpInst &ICI, BinaryOperator *DivI,
+ ConstantInt *DivRHS);
Instruction *foldICmpCstShrConst(ICmpInst &I, Value *Op, Value *A,
ConstantInt *CI1, ConstantInt *CI2);
Instruction *foldICmpCstShlConst(ICmpInst &I, Value *Op, Value *A,
@@ -560,6 +560,30 @@
ICmpInst::Predicate Pred);
Instruction *foldICmpWithCastAndCast(ICmpInst &ICI);
Instruction *foldICmpWithConstant(ICmpInst &ICI);
+
+ Instruction *foldICmpTruncConstant(ICmpInst &ICI, Instruction *LHSI,
+ const APInt *RHSV);
+ Instruction *foldICmpAndConstant(ICmpInst &ICI, Instruction *LHSI,
+ const APInt *RHSV);
+ Instruction *foldICmpXorConstant(ICmpInst &ICI, Instruction *LHSI,
+ const APInt *RHSV);
+ Instruction *foldICmpOrConstant(ICmpInst &ICI, Instruction *LHSI,
+ const APInt *RHSV);
+ Instruction *foldICmpMulConstant(ICmpInst &ICI, Instruction *LHSI,
+ const APInt *RHSV);
+ Instruction *foldICmpShlConstant(ICmpInst &ICI, Instruction *LHSI,
+ const APInt *RHSV);
+ Instruction *foldICmpShrConstant(ICmpInst &ICI, Instruction *LHSI,
+ const APInt *RHSV);
+ Instruction *foldICmpUDivConstant(ICmpInst &ICI, Instruction *LHSI,
+ const APInt *RHSV);
+ Instruction *foldICmpDivConstant(ICmpInst &ICI, Instruction *LHSI,
+ const APInt *RHSV);
+ Instruction *foldICmpSubConstant(ICmpInst &ICI, Instruction *LHSI,
+ const APInt *RHSV);
+ Instruction *foldICmpAddConstant(ICmpInst &ICI, Instruction *LHSI,
+ const APInt *RHSV);
+
Instruction *foldICmpEqualityWithConstant(ICmpInst &ICI);
Instruction *foldICmpIntrinsicWithConstant(ICmpInst &ICI);