-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[GVN] Turn off ScalarPRE for TokenLike Types #156513
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
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -S -passes=gvn %s | FileCheck %s | ||
|
||
; NOTE: A test to confirm GVN doesn't introduce phis for token like types. | ||
; NOTE: This implies the CHECKS should exactly match the IR. | ||
|
||
%"$Globals" = type { i32 } | ||
@CBV = external constant %"$Globals" | ||
@Out.str = private unnamed_addr constant [4 x i8] c"Out\00", align 1 | ||
|
||
define i32 @CSMain() local_unnamed_addr { | ||
; CHECK-LABEL: define i32 @CSMain() local_unnamed_addr { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[LOADGLOBAL:%.*]] = load i32, ptr @CBV, align 4 | ||
; CHECK-NEXT: [[CMP_I1_NOT:%.*]] = icmp eq i32 [[LOADGLOBAL]], 0 | ||
; CHECK-NEXT: br i1 [[CMP_I1_NOT]], label %[[CSMAIN_EXIT:.*]], label %[[FOR_BODY_I_LR_PH:.*]] | ||
; CHECK: [[FOR_BODY_I_LR_PH]]: | ||
; CHECK-NEXT: [[BUF:%.*]] = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i32_1_0t(i32 0, i32 0, i32 4, i32 [[LOADGLOBAL]], ptr nonnull @Out.str) | ||
; CHECK-NEXT: br label %[[FOR_BODY_I:.*]] | ||
; CHECK: [[FOR_BODY_I]]: | ||
; CHECK-NEXT: [[LOOPPHI:%.*]] = phi i32 [ 0, %[[FOR_BODY_I_LR_PH]] ], [ [[INC_I:%.*]], %[[FOR_BODY_I]] ] | ||
; CHECK-NEXT: [[UPDATECNT:%.*]] = tail call noundef i32 @llvm.dx.resource.updatecounter.tdx.RawBuffer_i32_1_0t(target("dx.RawBuffer", i32, 1, 0) [[BUF]], i8 1) | ||
; CHECK-NEXT: [[INC_I]] = add nuw nsw i32 [[LOOPPHI]], 1 | ||
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[INC_I]], [[LOADGLOBAL]] | ||
; CHECK-NEXT: br i1 [[EXITCOND]], label %[[FOR_BODY_I]], label %[[CSMAIN_EXIT]] | ||
; CHECK: [[CSMAIN_EXIT]]: | ||
; CHECK-NEXT: [[BUFEXIT:%.*]] = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i32_1_0t(i32 0, i32 0, i32 4, i32 [[LOADGLOBAL]], ptr nonnull @Out.str) | ||
; CHECK-NEXT: [[UPDATECNTEXIT:%.*]] = tail call noundef i32 @llvm.dx.resource.updatecounter.tdx.RawBuffer_i32_1_0t(target("dx.RawBuffer", i32, 1, 0) [[BUFEXIT]], i8 1) | ||
; CHECK-NEXT: ret i32 [[UPDATECNTEXIT]] | ||
; | ||
entry: | ||
%loadGlobal = load i32, ptr @CBV, align 4 | ||
%cmp.i1.not = icmp eq i32 %loadGlobal, 0 | ||
br i1 %cmp.i1.not, label %CSMain.exit, label %for.body.i.lr.ph | ||
|
||
for.body.i.lr.ph: | ||
%buf = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 4, i32 %loadGlobal, ptr nonnull @Out.str) | ||
br label %for.body.i | ||
|
||
for.body.i: | ||
%loopPhi = phi i32 [ 0, %for.body.i.lr.ph ], [ %inc.i, %for.body.i ] | ||
%updateCnt = tail call noundef i32 @llvm.dx.resource.updatecounter(target("dx.RawBuffer", i32, 1, 0) %buf, i8 1) | ||
%inc.i = add nuw nsw i32 %loopPhi, 1 | ||
%exitcond = icmp ne i32 %inc.i, %loadGlobal | ||
br i1 %exitcond, label %for.body.i, label %CSMain.exit | ||
|
||
CSMain.exit: | ||
%bufExit = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 4, i32 %loadGlobal, ptr nonnull @Out.str) | ||
%updateCntExit = tail call noundef i32 @llvm.dx.resource.updatecounter(target("dx.RawBuffer", i32, 1, 0) %bufExit, i8 1) | ||
ret i32 %updateCntExit | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there can be phi nodes just not on Token like types. This would likely break the phi in the for loop. I think what exist is sufficent because if a phi were to show up later this test would fail and then someone would come read this note.