Skip to content

Commit 989ac2d

Browse files
committed
[ValueTracking] Handle range assume bundles in computeConstantRange
1 parent d6f1964 commit 989ac2d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9913,11 +9913,17 @@ ConstantRange llvm::computeConstantRange(const Value *V, bool ForSigned,
99139913
for (auto &AssumeVH : AC->assumptionsFor(V)) {
99149914
if (!AssumeVH)
99159915
continue;
9916-
CallInst *I = cast<CallInst>(AssumeVH);
9916+
AssumeInst *I = cast<AssumeInst>(AssumeVH);
99179917
assert(I->getParent()->getParent() == CtxI->getParent()->getParent() &&
99189918
"Got assumption for the wrong function!");
9919-
assert(I->getIntrinsicID() == Intrinsic::assume &&
9920-
"must be an assume intrinsic");
9919+
9920+
if (AssumeVH.Index != AssumptionCache::ExprResultIdx) {
9921+
if (std::optional<ConstantRange> Range = getRangeFromBundle(
9922+
*I, I->bundle_op_info_begin()[AssumeVH.Index]))
9923+
if (isValidAssumeForContext(I, CtxI, DT))
9924+
CR = CR.intersectWith(*Range);
9925+
continue;
9926+
}
99219927

99229928
if (!isValidAssumeForContext(I, CtxI, DT))
99239929
continue;

llvm/test/Analysis/BasicAA/range.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ entry:
272272
}
273273

274274
; CHECK-LABEL: Function: range_assume
275-
; CHECK: MayAlias: i32* %gep1, i32* %gep2
275+
; CHECK: NoAlias: i32* %gep1, i32* %gep2
276276
define void @range_assume(ptr %s, ptr %q) {
277277
%in_array = load i32, ptr %q
278278
call void @llvm.assume(i1 true) ["range"(i32 %in_array, i32 0, i32 2)]

0 commit comments

Comments
 (0)