Skip to content

[IPSCCP] Infer attributes on arguments #107114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/include/llvm/IR/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
/// gets the attribute from the list of attributes.
Attribute getAttributeAtIndex(unsigned i, StringRef Kind) const;

/// Check if attribute of the given kind is set at the given index.
bool hasAttributeAtIndex(unsigned Idx, Attribute::AttrKind Kind) const;

/// Return the attribute for the given attribute kind.
Attribute getFnAttribute(Attribute::AttrKind Kind) const;

Expand Down
3 changes: 3 additions & 0 deletions llvm/include/llvm/Transforms/Utils/SCCPSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class SCCPSolver {
/// argument-tracked functions.
bool isArgumentTrackedFunction(Function *F);

const SmallPtrSetImpl<Function *> &getArgumentTrackedFunctions() const;

/// Solve - Solve for constants and executable blocks.
void solve();

Expand Down Expand Up @@ -191,6 +193,7 @@ class SCCPSolver {
BasicBlock *&NewUnreachableBB) const;

void inferReturnAttributes() const;
void inferArgAttributes() const;

bool tryToReplaceWithConstant(Value *V);

Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/IR/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,11 @@ Attribute Function::getAttributeAtIndex(unsigned i, StringRef Kind) const {
return AttributeSets.getAttributeAtIndex(i, Kind);
}

bool Function::hasAttributeAtIndex(unsigned Idx,
Attribute::AttrKind Kind) const {
return AttributeSets.hasAttributeAtIndex(Idx, Kind);
}

Attribute Function::getFnAttribute(Attribute::AttrKind Kind) const {
return AttributeSets.getFnAttr(Kind);
}
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Transforms/IPO/SCCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ static bool runIPSCCP(
SmallVector<ReturnInst*, 8> ReturnsToZap;

Solver.inferReturnAttributes();
Solver.inferArgAttributes();
for (const auto &[F, ReturnValue] : Solver.getTrackedRetVals()) {
assert(!F->getReturnType()->isVoidTy() &&
"should not track void functions");
Expand Down
67 changes: 45 additions & 22 deletions llvm/lib/Transforms/Utils/SCCPSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,31 +341,45 @@ bool SCCPSolver::removeNonFeasibleEdges(BasicBlock *BB, DomTreeUpdater &DTU,
return true;
}

static void inferAttribute(Function *F, unsigned AttrIndex,
const ValueLatticeElement &Val) {
// If there is a known constant range for the value, add range attribute.
if (Val.isConstantRange() && !Val.getConstantRange().isSingleElement()) {
// Do not add range attribute if the value may include undef.
if (Val.isConstantRangeIncludingUndef())
return;

// Take the intersection of the existing attribute and the inferred range.
Attribute OldAttr = F->getAttributeAtIndex(AttrIndex, Attribute::Range);
ConstantRange CR = Val.getConstantRange();
if (OldAttr.isValid())
CR = CR.intersectWith(OldAttr.getRange());
F->addAttributeAtIndex(
AttrIndex, Attribute::get(F->getContext(), Attribute::Range, CR));
return;
}
// Infer nonnull attribute.
if (Val.isNotConstant() && Val.getNotConstant()->getType()->isPointerTy() &&
Val.getNotConstant()->isNullValue() &&
!F->hasAttributeAtIndex(AttrIndex, Attribute::NonNull)) {
F->addAttributeAtIndex(AttrIndex,
Attribute::get(F->getContext(), Attribute::NonNull));
}
}

void SCCPSolver::inferReturnAttributes() const {
for (const auto &[F, ReturnValue] : getTrackedRetVals()) {

// If there is a known constant range for the return value, add range
// attribute to the return value.
if (ReturnValue.isConstantRange() &&
!ReturnValue.getConstantRange().isSingleElement()) {
// Do not add range metadata if the return value may include undef.
if (ReturnValue.isConstantRangeIncludingUndef())
continue;
for (const auto &[F, ReturnValue] : getTrackedRetVals())
inferAttribute(F, AttributeList::ReturnIndex, ReturnValue);
}

// Take the intersection of the existing attribute and the inferred range.
ConstantRange CR = ReturnValue.getConstantRange();
if (F->hasRetAttribute(Attribute::Range))
CR = CR.intersectWith(F->getRetAttribute(Attribute::Range).getRange());
F->addRangeRetAttr(CR);
continue;
}
// Infer nonnull return attribute.
if (F->getReturnType()->isPointerTy() && ReturnValue.isNotConstant() &&
ReturnValue.getNotConstant()->isNullValue() &&
!F->hasRetAttribute(Attribute::NonNull)) {
F->addRetAttr(Attribute::NonNull);
void SCCPSolver::inferArgAttributes() const {
for (Function *F : getArgumentTrackedFunctions()) {
if (!isBlockExecutable(&F->front()))
continue;
}
for (Argument &A : F->args())
if (!A.getType()->isStructTy())
inferAttribute(F, AttributeList::FirstArgIndex + A.getArgNo(),
getLatticeValueFor(&A));
}
}

Expand Down Expand Up @@ -766,6 +780,10 @@ class SCCPInstVisitor : public InstVisitor<SCCPInstVisitor> {
return TrackingIncomingArguments.count(F);
}

const SmallPtrSetImpl<Function *> &getArgumentTrackedFunctions() const {
return TrackingIncomingArguments;
}

void solve();

bool resolvedUndef(Instruction &I);
Expand Down Expand Up @@ -2140,6 +2158,11 @@ bool SCCPSolver::isArgumentTrackedFunction(Function *F) {
return Visitor->isArgumentTrackedFunction(F);
}

const SmallPtrSetImpl<Function *> &
SCCPSolver::getArgumentTrackedFunctions() const {
return Visitor->getArgumentTrackedFunctions();
}

void SCCPSolver::solve() { Visitor->solve(); }

bool SCCPSolver::resolvedUndefsIn(Function &F) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ entry:

define internal i64 @foo(i64 %n, i1 %c1, i1 %c2, i1 %c3, i1 %c4, i1 %c5, i1 %c6, i1 %c7, i1 %c8, i1 %c9, i1 %c10) {
; NOFUNCSPEC-LABEL: define internal range(i64 2, 7) i64 @foo(
; NOFUNCSPEC-SAME: i64 [[N:%.*]], i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]], i1 [[C4:%.*]], i1 [[C5:%.*]], i1 [[C6:%.*]], i1 [[C7:%.*]], i1 [[C8:%.*]], i1 [[C9:%.*]], i1 [[C10:%.*]]) {
; NOFUNCSPEC-SAME: i64 range(i64 3, 5) [[N:%.*]], i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]], i1 [[C4:%.*]], i1 [[C5:%.*]], i1 [[C6:%.*]], i1 [[C7:%.*]], i1 [[C8:%.*]], i1 [[C9:%.*]], i1 [[C10:%.*]]) {
; NOFUNCSPEC-NEXT: entry:
; NOFUNCSPEC-NEXT: br i1 [[C1]], label [[L1:%.*]], label [[L9:%.*]]
; NOFUNCSPEC: l1:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/SCCP/ip-add-range-to-call.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
; can be added to call sites.
define internal i32 @callee(i32 %x) {
; CHECK-LABEL: define internal range(i32 0, 21) i32 @callee(
; CHECK-SAME: i32 [[X:%.*]]) {
; CHECK-SAME: i32 range(i32 0, 21) [[X:%.*]]) {
; CHECK-NEXT: ret i32 [[X]]
;
ret i32 %x
Expand Down Expand Up @@ -133,7 +133,7 @@ define void @caller_cb3() {
; should be added at call sites.
define internal i32 @callee5(i32 %x, i32 %y) {
; CHECK-LABEL: define internal i32 @callee5(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {
; CHECK-SAME: i32 range(i32 10, 21) [[X:%.*]], i32 range(i32 100, 201) [[Y:%.*]]) {
; CHECK-NEXT: [[C:%.*]] = icmp slt i32 [[X]], 15
; CHECK-NEXT: br i1 [[C]], label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
Expand Down
16 changes: 8 additions & 8 deletions llvm/test/Transforms/SCCP/ip-constant-ranges.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
; Constant range for %a is [1, 48) and for %b is [301, 1000)
define internal i32 @f1(i32 %a, i32 %b) {
; CHECK-LABEL: define {{[^@]+}}@f1
; CHECK-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) {
; CHECK-SAME: (i32 range(i32 1, 48) [[A:%.*]], i32 range(i32 301, 1000) [[B:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 poison
;
Expand All @@ -27,7 +27,7 @@ entry:
; Constant range for %x is [47, 302)
define internal i32 @f2(i32 %x) {
; CHECK-LABEL: define {{[^@]+}}@f2
; CHECK-SAME: (i32 [[X:%.*]]) {
; CHECK-SAME: (i32 range(i32 47, 302) [[X:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X]], 300
; CHECK-NEXT: [[CMP4:%.*]] = icmp ugt i32 [[X]], 300
Expand Down Expand Up @@ -79,7 +79,7 @@ entry:

define internal i32 @f3(i32 %x) {
; CHECK-LABEL: define {{[^@]+}}@f3
; CHECK-SAME: (i32 [[X:%.*]]) {
; CHECK-SAME: (i32 range(i32 0, 2) [[X:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 poison
;
Expand Down Expand Up @@ -116,7 +116,7 @@ end:

define internal i32 @f4(i32 %x) {
; CHECK-LABEL: define {{[^@]+}}@f4
; CHECK-SAME: (i32 [[X:%.*]]) {
; CHECK-SAME: (i32 range(i32 301, -2147483648) [[X:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 poison
;
Expand Down Expand Up @@ -170,7 +170,7 @@ entry:

define internal i1 @test_unreachable_callee(i32 %a) {
; CHECK-LABEL: define {{[^@]+}}@test_unreachable_callee
; CHECK-SAME: (i32 [[A:%.*]]) {
; CHECK-SAME: (i32 range(i32 1, 3) [[A:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i1 poison
;
Expand Down Expand Up @@ -199,7 +199,7 @@ define double @test_struct({ double, double } %test) {
; Constant range for %x is [47, 302)
define internal i32 @f5(i32 %x) {
; CHECK-LABEL: define {{[^@]+}}@f5
; CHECK-SAME: (i32 [[X:%.*]]) {
; CHECK-SAME: (i32 range(i32 47, 302) [[X:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X]], undef
; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i32 undef, [[X]]
Expand Down Expand Up @@ -282,7 +282,7 @@ entry:

define internal i32 @callee6.1(i32 %i) {
; CHECK-LABEL: define {{[^@]+}}@callee6.1
; CHECK-SAME: (i32 [[I:%.*]]) {
; CHECK-SAME: (i32 range(i32 30, 44) [[I:%.*]]) {
; CHECK-NEXT: [[RES:%.*]] = call i32 @callee6.2(i32 [[I]])
; CHECK-NEXT: ret i32 poison
;
Expand All @@ -292,7 +292,7 @@ define internal i32 @callee6.1(i32 %i) {

define internal i32 @callee6.2(i32 %i) {
; CHECK-LABEL: define {{[^@]+}}@callee6.2
; CHECK-SAME: (i32 [[I:%.*]]) {
; CHECK-SAME: (i32 range(i32 30, 44) [[I:%.*]]) {
; CHECK-NEXT: br label [[IF_THEN:%.*]]
; CHECK: if.then:
; CHECK-NEXT: ret i32 poison
Expand Down
14 changes: 7 additions & 7 deletions llvm/test/Transforms/SCCP/ip-ranges-casts.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
; x = [100, 301)
define internal i1 @f.trunc(i32 %x) {
; CHECK-LABEL: define internal i1 @f.trunc(
; CHECK-SAME: i32 [[X:%.*]]) {
; CHECK-SAME: i32 range(i32 100, 301) [[X:%.*]]) {
; CHECK-NEXT: [[T_1:%.*]] = trunc nuw nsw i32 [[X]] to i16
; CHECK-NEXT: [[C_2:%.*]] = icmp sgt i16 [[T_1]], 299
; CHECK-NEXT: [[C_4:%.*]] = icmp slt i16 [[T_1]], 101
Expand Down Expand Up @@ -60,7 +60,7 @@ define i1 @caller1() {
; x = [100, 301)
define internal i1 @f.zext(i32 %x, i32 %y) {
; CHECK-LABEL: define internal i1 @f.zext(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {
; CHECK-SAME: i32 range(i32 100, 301) [[X:%.*]], i32 range(i32 -120, 901) [[Y:%.*]]) {
; CHECK-NEXT: [[T_1:%.*]] = zext nneg i32 [[X]] to i64
; CHECK-NEXT: [[C_2:%.*]] = icmp sgt i64 [[T_1]], 299
; CHECK-NEXT: [[C_4:%.*]] = icmp slt i64 [[T_1]], 101
Expand Down Expand Up @@ -114,7 +114,7 @@ define i1 @caller.zext() {
; x = [100, 301)
define internal i1 @f.sext(i32 %x, i32 %y) {
; CHECK-LABEL: define internal i1 @f.sext(
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {
; CHECK-SAME: i32 range(i32 100, 301) [[X:%.*]], i32 range(i32 -120, 901) [[Y:%.*]]) {
; CHECK-NEXT: [[T_1:%.*]] = zext nneg i32 [[X]] to i64
; CHECK-NEXT: [[C_2:%.*]] = icmp sgt i64 [[T_1]], 299
; CHECK-NEXT: [[C_4:%.*]] = icmp slt i64 [[T_1]], 101
Expand Down Expand Up @@ -166,7 +166,7 @@ define i1 @caller.sext() {
; There's nothing we can do besides going to the full range or overdefined.
define internal i1 @f.fptosi(i32 %x) {
; CHECK-LABEL: define internal i1 @f.fptosi(
; CHECK-SAME: i32 [[X:%.*]]) {
; CHECK-SAME: i32 range(i32 100, 301) [[X:%.*]]) {
; CHECK-NEXT: [[TO_DOUBLE:%.*]] = uitofp nneg i32 [[X]] to double
; CHECK-NEXT: [[ADD:%.*]] = fadd double 0.000000e+00, [[TO_DOUBLE]]
; CHECK-NEXT: [[TO_I32:%.*]] = fptosi double [[ADD]] to i32
Expand Down Expand Up @@ -208,7 +208,7 @@ define i1 @caller.fptosi() {
; There's nothing we can do besides going to the full range or overdefined.
define internal i1 @f.fpext(i16 %x) {
; CHECK-LABEL: define internal i1 @f.fpext(
; CHECK-SAME: i16 [[X:%.*]]) {
; CHECK-SAME: i16 range(i16 100, 301) [[X:%.*]]) {
; CHECK-NEXT: [[TO_FLOAT:%.*]] = uitofp nneg i16 [[X]] to float
; CHECK-NEXT: [[TO_DOUBLE:%.*]] = fpext float [[TO_FLOAT]] to double
; CHECK-NEXT: [[TO_I64:%.*]] = fptoui float [[TO_FLOAT]] to i64
Expand Down Expand Up @@ -251,7 +251,7 @@ define i1 @caller.fpext() {
; There's nothing we can do besides going to the full range or overdefined.
define internal i1 @f.inttoptr.ptrtoint(i64 %x) {
; CHECK-LABEL: define internal i1 @f.inttoptr.ptrtoint(
; CHECK-SAME: i64 [[X:%.*]]) {
; CHECK-SAME: i64 range(i64 100, 301) [[X:%.*]]) {
; CHECK-NEXT: [[TO_PTR:%.*]] = inttoptr i64 [[X]] to ptr
; CHECK-NEXT: [[TO_I64:%.*]] = ptrtoint ptr [[TO_PTR]] to i64
; CHECK-NEXT: [[C_1:%.*]] = icmp sgt i64 [[TO_I64]], 300
Expand Down Expand Up @@ -325,7 +325,7 @@ entry:

define internal i64 @f.sext_to_zext(i32 %t) {
; CHECK-LABEL: define internal range(i64 0, 2) i64 @f.sext_to_zext(
; CHECK-SAME: i32 [[T:%.*]]) {
; CHECK-SAME: i32 range(i32 0, 2) [[T:%.*]]) {
; CHECK-NEXT: [[A:%.*]] = zext nneg i32 [[T]] to i64
; CHECK-NEXT: ret i64 [[A]]
;
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/Transforms/SCCP/ip-ranges-phis.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

define internal i32 @f1(i32 %x) {
; CHECK-LABEL: define {{[^@]+}}@f1
; CHECK-SAME: (i32 [[X:%.*]]) {
; CHECK-SAME: (i32 range(i32 0, 2) [[X:%.*]]) {
; CHECK-NEXT: ret i32 poison
;
%cmp = icmp sgt i32 %x, 300
Expand Down Expand Up @@ -40,7 +40,7 @@ end:

define internal i32 @f2(i32 %x, i32 %y, i32 %z, i1 %cmp.1, i1 %cmp.2) {
; CHECK-LABEL: define {{[^@]+}}@f2
; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]], i1 [[CMP_1:%.*]], i1 [[CMP_2:%.*]]) {
; CHECK-SAME: (i32 range(i32 0, 2) [[X:%.*]], i32 range(i32 -10, 2) [[Y:%.*]], i32 range(i32 1, 11) [[Z:%.*]], i1 [[CMP_1:%.*]], i1 [[CMP_2:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[CMP_1]], label [[IF_TRUE_1:%.*]], label [[END:%.*]]
; CHECK: if.true.1:
Expand Down Expand Up @@ -133,7 +133,7 @@ end:

define internal i32 @f3(i32 %x, i32 %y, i1 %cmp.1) {
; CHECK-LABEL: define {{[^@]+}}@f3
; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]], i1 [[CMP_1:%.*]]) {
; CHECK-SAME: (i32 range(i32 0, 6) [[X:%.*]], i32 [[Y:%.*]], i1 [[CMP_1:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[CMP_1]], label [[IF_TRUE_1:%.*]], label [[END:%.*]]
; CHECK: if.true.1:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/SCCP/ip-ranges-select.ll
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define void @caller.1(ptr %arg) {

define internal i32 @callee.1(i32 %arg) {
; CHECK-LABEL: define {{[^@]+}}@callee.1
; CHECK-SAME: (i32 [[ARG:%.*]]) {
; CHECK-SAME: (i32 range(i32 2, 5) [[ARG:%.*]]) {
; CHECK-NEXT: [[SEL:%.*]] = select i1 false, i32 16, i32 [[ARG]]
; CHECK-NEXT: br label [[BB10:%.*]]
; CHECK: bb10:
Expand All @@ -40,7 +40,7 @@ declare void @use(i32)

define internal i1 @f1(i32 %x, i32 %y, i1 %cmp) {
; CHECK-LABEL: define {{[^@]+}}@f1
; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]], i1 [[CMP:%.*]]) {
; CHECK-SAME: (i32 range(i32 10, 21) [[X:%.*]], i32 range(i32 100, 201) [[Y:%.*]], i1 [[CMP:%.*]]) {
; CHECK-NEXT: [[SEL_1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[Y]]
; CHECK-NEXT: [[C_2:%.*]] = icmp sgt i32 [[SEL_1]], 100
; CHECK-NEXT: [[C_3:%.*]] = icmp eq i32 [[SEL_1]], 50
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/SCCP/musttail-call.ll
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ define internal ptr @no_side_effects(i8 %v) readonly nounwind willreturn {
; return value should stay as it is, and should not be zapped.
define internal ptr @dont_zap_me(i8 %v) {
; CHECK-LABEL: define {{[^@]+}}@dont_zap_me
; CHECK-SAME: (i8 [[V:%.*]]) {
; CHECK-SAME: (i8 range(i8 2, 0) [[V:%.*]]) {
; CHECK-NEXT: [[I1:%.*]] = call i32 @external()
; CHECK-NEXT: ret ptr null
;
Expand Down
10 changes: 7 additions & 3 deletions llvm/test/Transforms/SCCP/pointer-nonnull.ll
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,13 @@ define ptr @ret_maybe_null_pointer(ptr %p) {
}

define internal void @ip_nonnull_arg_callee(ptr %p) {
; CHECK-LABEL: define internal void @ip_nonnull_arg_callee(
; CHECK-SAME: ptr [[P:%.*]]) {
; CHECK-NEXT: ret void
; SCCP-LABEL: define internal void @ip_nonnull_arg_callee(
; SCCP-SAME: ptr [[P:%.*]]) {
; SCCP-NEXT: ret void
;
; IPSCCP-LABEL: define internal void @ip_nonnull_arg_callee(
; IPSCCP-SAME: ptr nonnull [[P:%.*]]) {
; IPSCCP-NEXT: ret void
;
ret void
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/SCCP/resolvedundefsin-tracked-fn.ll
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ entry:

define internal i1 @test1_g(ptr %h, i32 %i) #0 {
; CHECK-LABEL: define {{[^@]+}}@test1_g
; CHECK-SAME: (ptr [[H:%.*]], i32 [[I:%.*]]) {
; CHECK-SAME: (ptr [[H:%.*]], i32 range(i32 0, 2) [[I:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[I]], 0
; CHECK-NEXT: br i1 [[TOBOOL]], label [[LAND_RHS:%.*]], label [[LAND_END:%.*]]
Expand Down Expand Up @@ -221,7 +221,7 @@ exit:

define internal i1 @test3_g(ptr %h, i32 %i) {
; CHECK-LABEL: define {{[^@]+}}@test3_g
; CHECK-SAME: (ptr [[H:%.*]], i32 [[I:%.*]]) {
; CHECK-SAME: (ptr [[H:%.*]], i32 range(i32 0, 2) [[I:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[I]], 0
; CHECK-NEXT: br i1 [[TOBOOL]], label [[LAND_RHS:%.*]], label [[LAND_END:%.*]]
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/SCCP/switch.ll
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ switch.2:
; range information.
define internal i32 @test_ip_range(i32 %x) {
; CHECK-LABEL: define internal range(i32 1, 4) i32 @test_ip_range(
; CHECK-SAME: i32 [[X:%.*]]) {
; CHECK-SAME: i32 range(i32 1, 4) [[X:%.*]]) {
; CHECK-NEXT: switch i32 [[X]], label [[DEFAULT_UNREACHABLE:%.*]] [
; CHECK-NEXT: i32 3, label [[SWITCH_3:%.*]]
; CHECK-NEXT: i32 1, label [[SWITCH_1:%.*]]
Expand Down
Loading