-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Pipelines] Perform mergefunc after constmerge #92498
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
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1c8845a
[Pipelines] Perform mergefunc after constmerge
yamt a6d30c8
add a few tests
yamt 174dd17
drop tbaa metadata
yamt 2d3dc73
drop attributes
yamt 003cb54
apply utils/update_test_checks.py
yamt ecd9a4b
remove stray attribute group ids
yamt bd82e91
remove stale comments
yamt 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
76 changes: 76 additions & 0 deletions
76
llvm/test/Transforms/PhaseOrdering/X86/merge-functions2.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,76 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -passes="default<O3>" -enable-merge-functions -S < %s | FileCheck %s | ||
|
||
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-apple-macosx12.0.0" | ||
|
||
define i32 @f(i32 noundef %x) { | ||
; CHECK-LABEL: define range(i32 0, 2) i32 @f( | ||
; CHECK-SAME: i32 noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { | ||
; CHECK-NEXT: [[ENTRY:.*]]: | ||
; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i32 [[X]], 8 | ||
; CHECK-NEXT: br i1 [[TMP0]], label %[[SWITCH_LOOKUP:.*]], label %[[SW_EPILOG:.*]] | ||
; CHECK: [[SWITCH_LOOKUP]]: | ||
; CHECK-NEXT: [[TMP1:%.*]] = zext nneg i32 [[X]] to i64 | ||
; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [8 x i32], ptr @switch.table.g, i64 0, i64 [[TMP1]] | ||
; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i32, ptr [[SWITCH_GEP]], align 4 | ||
; CHECK-NEXT: br label %[[SW_EPILOG]] | ||
; CHECK: [[SW_EPILOG]]: | ||
; CHECK-NEXT: [[X_ADDR_0:%.*]] = phi i32 [ [[SWITCH_LOAD]], %[[SWITCH_LOOKUP]] ], [ 0, %[[ENTRY]] ] | ||
; CHECK-NEXT: ret i32 [[X_ADDR_0]] | ||
; | ||
entry: | ||
%x.addr = alloca i32, align 4 | ||
store i32 %x, ptr %x.addr, align 4 | ||
%0 = load i32, ptr %x.addr, align 4 | ||
switch i32 %0, label %sw.default [ | ||
i32 0, label %sw.bb | ||
i32 2, label %sw.bb | ||
i32 4, label %sw.bb | ||
i32 6, label %sw.bb | ||
i32 7, label %sw.bb | ||
] | ||
|
||
sw.bb: ; preds = %entry, %entry, %entry, %entry, %entry | ||
store i32 1, ptr %x.addr, align 4 | ||
br label %sw.epilog | ||
|
||
sw.default: ; preds = %entry | ||
store i32 0, ptr %x.addr, align 4 | ||
br label %sw.epilog | ||
|
||
sw.epilog: ; preds = %sw.default, %sw.bb | ||
%1 = load i32, ptr %x.addr, align 4 | ||
ret i32 %1 | ||
} | ||
|
||
define i32 @g(i32 noundef %x) { | ||
; CHECK-LABEL: define range(i32 0, 2) i32 @g( | ||
; CHECK-SAME: i32 noundef [[TMP0:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
; CHECK-NEXT: [[TMP2:%.*]] = tail call range(i32 0, 2) i32 @f(i32 noundef [[TMP0]]) #[[ATTR0]] | ||
; CHECK-NEXT: ret i32 [[TMP2]] | ||
; | ||
entry: | ||
%x.addr = alloca i32, align 4 | ||
store i32 %x, ptr %x.addr, align 4 | ||
%0 = load i32, ptr %x.addr, align 4 | ||
switch i32 %0, label %sw.default [ | ||
i32 0, label %sw.bb | ||
i32 2, label %sw.bb | ||
i32 4, label %sw.bb | ||
i32 6, label %sw.bb | ||
i32 7, label %sw.bb | ||
] | ||
|
||
sw.bb: ; preds = %entry, %entry, %entry, %entry, %entry | ||
store i32 1, ptr %x.addr, align 4 | ||
br label %sw.epilog | ||
|
||
sw.default: ; preds = %entry | ||
store i32 0, ptr %x.addr, align 4 | ||
br label %sw.epilog | ||
|
||
sw.epilog: ; preds = %sw.default, %sw.bb | ||
%1 = load i32, ptr %x.addr, align 4 | ||
ret i32 %1 | ||
} |
59 changes: 59 additions & 0 deletions
59
llvm/test/Transforms/PhaseOrdering/X86/merge-functions3.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,59 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -passes="default<O3>" -enable-merge-functions -S < %s | FileCheck %s | ||
|
||
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-apple-macosx12.0.0" | ||
|
||
@switch.table.f = private unnamed_addr constant [8 x i32] [i32 1, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 1], align 4 | ||
@switch.table.g = private unnamed_addr constant [8 x i32] [i32 1, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 1], align 4 | ||
|
||
define range(i32 0, 2) i32 @f(i32 noundef %x) local_unnamed_addr { | ||
; CHECK-LABEL: define range(i32 0, 2) i32 @f( | ||
; CHECK-SAME: i32 noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { | ||
; CHECK-NEXT: [[ENTRY:.*]]: | ||
; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i32 [[X]], 8 | ||
; CHECK-NEXT: br i1 [[TMP0]], label %[[SWITCH_LOOKUP:.*]], label %[[SW_EPILOG:.*]] | ||
; CHECK: [[SWITCH_LOOKUP]]: | ||
; CHECK-NEXT: [[TMP1:%.*]] = zext nneg i32 [[X]] to i64 | ||
; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [8 x i32], ptr @switch.table.g, i64 0, i64 [[TMP1]] | ||
; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i32, ptr [[SWITCH_GEP]], align 4 | ||
; CHECK-NEXT: br label %[[SW_EPILOG]] | ||
; CHECK: [[SW_EPILOG]]: | ||
; CHECK-NEXT: [[X_ADDR_0:%.*]] = phi i32 [ [[SWITCH_LOAD]], %[[SWITCH_LOOKUP]] ], [ 0, %[[ENTRY]] ] | ||
; CHECK-NEXT: ret i32 [[X_ADDR_0]] | ||
; | ||
entry: | ||
%0 = icmp ult i32 %x, 8 | ||
br i1 %0, label %switch.lookup, label %sw.epilog | ||
|
||
switch.lookup: ; preds = %entry | ||
%1 = zext nneg i32 %x to i64 | ||
%switch.gep = getelementptr inbounds [8 x i32], ptr @switch.table.f, i64 0, i64 %1 | ||
%switch.load = load i32, ptr %switch.gep, align 4 | ||
br label %sw.epilog | ||
|
||
sw.epilog: ; preds = %entry, %switch.lookup | ||
%x.addr.0 = phi i32 [ %switch.load, %switch.lookup ], [ 0, %entry ] | ||
ret i32 %x.addr.0 | ||
} | ||
|
||
define range(i32 0, 2) i32 @g(i32 noundef %x) local_unnamed_addr { | ||
; CHECK-LABEL: define range(i32 0, 2) i32 @g( | ||
; CHECK-SAME: i32 noundef [[TMP0:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
; CHECK-NEXT: [[TMP2:%.*]] = tail call range(i32 0, 2) i32 @f(i32 noundef [[TMP0]]) #[[ATTR0]] | ||
; CHECK-NEXT: ret i32 [[TMP2]] | ||
; | ||
entry: | ||
%0 = icmp ult i32 %x, 8 | ||
br i1 %0, label %switch.lookup, label %sw.epilog | ||
|
||
switch.lookup: ; preds = %entry | ||
%1 = zext nneg i32 %x to i64 | ||
%switch.gep = getelementptr inbounds [8 x i32], ptr @switch.table.g, i64 0, i64 %1 | ||
%switch.load = load i32, ptr %switch.gep, align 4 | ||
br label %sw.epilog | ||
|
||
sw.epilog: ; preds = %entry, %switch.lookup | ||
%x.addr.0 = phi i32 [ %switch.load, %switch.lookup ], [ 0, %entry ] | ||
ret i32 %x.addr.0 | ||
} |
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.