-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[FuncSpec] Query SCCPSolver in more places #114964
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
llvm/test/Transforms/FunctionSpecialization/solver-constants.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs --version 5 | ||
; RUN: opt -passes="ipsccp<func-spec>" -funcspec-min-function-size=1 \ | ||
; RUN: -funcspec-for-literal-constant=true \ | ||
; RUN: -funcspec-min-codesize-savings=50 \ | ||
; RUN: -funcspec-min-latency-savings=0 \ | ||
; RUN: -S < %s | FileCheck %s | ||
|
||
; Verify that we are able to estimate the codesize savings arising from a branch | ||
; based on a binary operator, where one operand is already found constant by | ||
; IPSCCP. | ||
define i32 @main(i1 %flag) { | ||
%notspec = call i32 @test(i1 %flag, i1 false) | ||
%spec = call i32 @test(i1 false, i1 false) | ||
%sum = add i32 %notspec, %spec | ||
ret i32 %sum | ||
} | ||
|
||
define internal i32 @test(i1 %argflag, i1 %constflag) { | ||
entry: | ||
%cond = or i1 %argflag, %constflag | ||
br i1 %cond, label %if.then, label %if.end | ||
|
||
if.then: | ||
call void @do_something() | ||
call void @do_something() | ||
call void @do_something() | ||
call void @do_something() | ||
br label %if.end | ||
|
||
if.end: | ||
%res = phi i32 [ 0, %entry ], [ 1, %if.then] | ||
ret i32 %res | ||
} | ||
|
||
declare void @do_something() | ||
; CHECK-LABEL: define range(i32 0, 2) i32 @main( | ||
; CHECK-SAME: i1 [[FLAG:%.*]]) { | ||
; CHECK-NEXT: [[NOTSPEC:%.*]] = call i32 @test(i1 [[FLAG]], i1 false) | ||
; CHECK-NEXT: [[SPEC:%.*]] = call i32 @test.specialized.1(i1 false, i1 false) | ||
; CHECK-NEXT: [[SUM:%.*]] = add nuw nsw i32 [[NOTSPEC]], 0 | ||
; CHECK-NEXT: ret i32 [[SUM]] | ||
; | ||
; | ||
; CHECK-LABEL: define internal range(i32 0, 2) i32 @test( | ||
; CHECK-SAME: i1 [[ARGFLAG:%.*]], i1 [[CONSTFLAG:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*]]: | ||
; CHECK-NEXT: [[COND:%.*]] = or i1 [[ARGFLAG]], false | ||
; CHECK-NEXT: br i1 [[COND]], label %[[IF_THEN:.*]], label %[[IF_END:.*]] | ||
; CHECK: [[IF_THEN]]: | ||
; CHECK-NEXT: call void @do_something() | ||
; CHECK-NEXT: call void @do_something() | ||
; CHECK-NEXT: call void @do_something() | ||
; CHECK-NEXT: call void @do_something() | ||
; CHECK-NEXT: br label %[[IF_END]] | ||
; CHECK: [[IF_END]]: | ||
; CHECK-NEXT: [[RES:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ 1, %[[IF_THEN]] ] | ||
; CHECK-NEXT: ret i32 [[RES]] | ||
; | ||
; | ||
; CHECK-LABEL: define internal i32 @test.specialized.1( | ||
; CHECK-SAME: i1 [[ARGFLAG:%.*]], i1 [[CONSTFLAG:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: br label %[[IF_END:.*]] | ||
; CHECK: [[IF_END]]: | ||
; CHECK-NEXT: ret i32 poison | ||
; |
74 changes: 74 additions & 0 deletions
74
llvm/test/Transforms/FunctionSpecialization/solver-dead-blocks.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs --version 5 | ||
; RUN: opt -passes="ipsccp<func-spec>" -funcspec-min-function-size=1 \ | ||
; RUN: -funcspec-for-literal-constant=true \ | ||
; RUN: -funcspec-min-codesize-savings=50 \ | ||
; RUN: -funcspec-min-latency-savings=0 \ | ||
; RUN: -S < %s | FileCheck %s | ||
|
||
; Verify that we are able to estimate the codesize savings arising from a block | ||
; which is found dead, where the block has a predecessor that was found dead by | ||
; IPSCCP. | ||
define i32 @main(i1 %flag) { | ||
%notspec = call i32 @test(i1 %flag, i1 true) | ||
%spec = call i32 @test(i1 true, i1 true) | ||
%sum = add i32 %notspec, %spec | ||
ret i32 %sum | ||
} | ||
|
||
define internal i32 @test(i1 %argflag, i1 %constflag) { | ||
entry: | ||
br i1 %argflag, label %block1, label %block3 | ||
|
||
block1: | ||
br i1 %constflag, label %end, label %block2 | ||
|
||
block2: | ||
br label %block3 | ||
|
||
block3: | ||
call void @do_something() | ||
call void @do_something() | ||
call void @do_something() | ||
call void @do_something() | ||
br label %end | ||
|
||
end: | ||
%res = phi i32 [ 0, %block1 ], [ 1, %block3] | ||
ret i32 %res | ||
} | ||
|
||
declare void @do_something() | ||
; CHECK-LABEL: define range(i32 0, 2) i32 @main( | ||
; CHECK-SAME: i1 [[FLAG:%.*]]) { | ||
; CHECK-NEXT: [[NOTSPEC:%.*]] = call i32 @test(i1 [[FLAG]], i1 true) | ||
; CHECK-NEXT: [[SPEC:%.*]] = call i32 @test.specialized.1(i1 true, i1 true) | ||
; CHECK-NEXT: [[SUM:%.*]] = add nuw nsw i32 [[NOTSPEC]], 0 | ||
; CHECK-NEXT: ret i32 [[SUM]] | ||
; | ||
; | ||
; CHECK-LABEL: define internal range(i32 0, 2) i32 @test( | ||
; CHECK-SAME: i1 [[ARGFLAG:%.*]], i1 [[CONSTFLAG:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: br i1 [[ARGFLAG]], label %[[BLOCK1:.*]], label %[[BLOCK3:.*]] | ||
; CHECK: [[BLOCK1]]: | ||
; CHECK-NEXT: br label %[[END:.*]] | ||
; CHECK: [[BLOCK3]]: | ||
; CHECK-NEXT: call void @do_something() | ||
; CHECK-NEXT: call void @do_something() | ||
; CHECK-NEXT: call void @do_something() | ||
; CHECK-NEXT: call void @do_something() | ||
; CHECK-NEXT: br label %[[END]] | ||
; CHECK: [[END]]: | ||
; CHECK-NEXT: [[RES:%.*]] = phi i32 [ 0, %[[BLOCK1]] ], [ 1, %[[BLOCK3]] ] | ||
; CHECK-NEXT: ret i32 [[RES]] | ||
; | ||
; | ||
; CHECK-LABEL: define internal i32 @test.specialized.1( | ||
; CHECK-SAME: i1 [[ARGFLAG:%.*]], i1 [[CONSTFLAG:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: br label %[[BLOCK1:.*]] | ||
; CHECK: [[BLOCK1]]: | ||
; CHECK-NEXT: br label %[[END:.*]] | ||
; CHECK: [[END]]: | ||
; CHECK-NEXT: ret i32 poison | ||
; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.