Repository navigation
[HLSL][DirectX] Avoid visited values when searching in hasNonUniformIndex
#189498
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
Changes from 5 commits
717dc6c
b97fd75
6a382ea
494493b
07fd932
4b2d051
79d39c2
d50ab38
c644221
616c4e9
223237d
07f9f79
a1be198
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||||||
| ; RUN: opt -S -dxil-intrinsic-expansion -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s | ||||||||||
|
|
||||||||||
| ; The goal of this test it to make sure compilation finishes successfully, | ||||||||||
| ; in bad case it should timeout. | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
|
|
||||||||||
| @Out.str = private unnamed_addr constant [4 x i8] c"Out\00", align 1 | ||||||||||
| ; CHECK-LABEL: define void @main | ||||||||||
| ; CHECK: call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 0, i32 %phi, i1 false) | ||||||||||
|
|
||||||||||
| define void @main() local_unnamed_addr { | ||||||||||
| entry: | ||||||||||
| %cmp = icmp eq i32 4, 0 | ||||||||||
| br i1 %cmp, label %_Z4mainj.exit, label %for.body.i | ||||||||||
|
|
||||||||||
| for.body.i: ; preds = %entry, %for.body.i | ||||||||||
| %phi = phi i32 [ %inc.loop, %for.body.i ], [ 0, %entry ] | ||||||||||
| %binding = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 4, i32 %phi, ptr nonnull @Out.str) | ||||||||||
| %inc.counter = tail call noundef i32 @llvm.dx.resource.updatecounter(target("dx.RawBuffer", i32, 1, 0) %binding, i8 1) | ||||||||||
| %inc.loop = add nuw nsw i32 %phi, 1 | ||||||||||
| %exitcond = icmp eq i32 %inc.loop, 4 | ||||||||||
| br i1 %exitcond, label %_Z4mainj.exit, label %for.body.i | ||||||||||
|
|
||||||||||
| _Z4mainj.exit: ; preds = %for.body.i, %entry | ||||||||||
| ret void | ||||||||||
| } | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| ; RUN: opt -S -dxil-intrinsic-expansion -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s | ||
|
|
||
| ; The goal of this test it to make sure compilation finishes successfully, | ||
| ; in bad case it should timeout. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test technically didn't hang, so this comment is a bit misleading. I also realize that it's a bit boring, in that we don't actually look at the phi node at all in this case. I wonder if a test based on something silly like this is a little bit more interesting, where the handlefrombinding still uses the value from the phi: https://hlsl.godbolt.org/z/TsaPzMhr5 Note that this never hung either, because when we see the function call we return early, but I think it's still a little bit interesting to have the case where we walk through the phi node at least once. |
||
|
|
||
|
|
||
| @Out.str = private unnamed_addr constant [4 x i8] c"Out\00", align 1 | ||
| ; CHECK-LABEL: define void @main | ||
| ; CHECK: call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 0, i32 %phi, i1 true) | ||
|
|
||
| define void @main() local_unnamed_addr { | ||
| entry: | ||
| %cmp = icmp eq i32 4, 0 | ||
| br i1 %cmp, label %_Z4mainj.exit, label %for.body.i | ||
|
|
||
| for.body.i: ; preds = %entry, %for.body.i | ||
| %phi = phi i32 [ %inc.loop, %for.body.i ], [ 0, %entry ] | ||
| %nuri = tail call noundef i32 @llvm.dx.resource.nonuniformindex(i32 %phi) | ||
| %binding = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 4, i32 %nuri, ptr nonnull @Out.str) | ||
| %inc.counter = tail call noundef i32 @llvm.dx.resource.updatecounter(target("dx.RawBuffer", i32, 1, 0) %binding, i8 1) | ||
| %inc.loop = add nuw nsw i32 %phi, 1 | ||
| %exitcond = icmp eq i32 %inc.loop, 4 | ||
| br i1 %exitcond, label %_Z4mainj.exit, label %for.body.i | ||
|
|
||
| _Z4mainj.exit: ; preds = %for.body.i, %entry | ||
| ret void | ||
| } | ||
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.
Instead of just checking that we avoid a timeout, we should check that the
NonUniformIndexargument to createHandle/createHandleFromBinding is set correctly to false. We should also have a version of the test that uses the index with@dx.resource.nonuniformindexthat tests that we correctly set that to true even when we have cyclic users.