[llvm] [InstCombine] Fold icmp(constants[x]) when the range of x is given (PR #67093)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 29 09:32:20 PST 2023
================
@@ -394,13 +409,15 @@ Instruction *InstCombinerImpl::foldCmpLoadFromIndexedGlobal(
// Look for an appropriate type:
// - The type of Idx if the magic fits
// - The smallest fitting legal type
- if (ArrayElementCount <= Idx->getType()->getIntegerBitWidth())
- Ty = Idx->getType();
+
+ if (ElementCountToTraverse <= PtrIdxTy->getIntegerBitWidth())
+ Ty = PtrIdxTy;
else
- Ty = DL.getSmallestLegalIntType(Init->getContext(), ArrayElementCount);
+ Ty = DL.getSmallestLegalIntType(Init->getContext(),
+ ElementCountToTraverse);
if (Ty) {
- Idx = MaskIdx(Idx);
+ Idx = LazyGetIndex(Idx);
Value *V = Builder.CreateIntCast(Idx, Ty, false);
V = Builder.CreateLShr(ConstantInt::get(Ty, MagicBitvector), V);
V = Builder.CreateAnd(ConstantInt::get(Ty, 1), V);
----------------
XChy wrote:
OK, I will post a separate PR for it later.
https://github.com/llvm/llvm-project/pull/67093
More information about the llvm-commits
mailing list