-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When incoming values of phinode do not match the inferred type of the phi node from users, keep the smallest type to make sure types can be lowered. This is fixing a bug found using tensorflow lite leading to an invalid SPIR-V code generated by clspv.
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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,26 @@ | ||
// RUN: clspv %s -o %t.spv | ||
// RUN: spirv-dis %t.spv -o %t.spvasm | ||
// RUN: spirv-val %t.spv --target-env spv1.0 | ||
// RUN: FileCheck %s < %t.spvasm | ||
|
||
// CHECK: [[uint:%[^ ]+]] = OpTypeInt 32 0 | ||
// CHECK: [[runtime:%[^ ]+]] = OpTypeRuntimeArray [[uint]] | ||
// CHECK: [[struct:%[^ ]+]] = OpTypeStruct [[runtime]] | ||
// CHECK: [[ptr:%[^ ]+]] = OpTypePointer StorageBuffer [[struct]] | ||
// CHECK: [[uint_ptr:%[^ ]+]] = OpTypePointer StorageBuffer [[uint]] | ||
// CHECK: [[var:%[^ ]+]] = OpVariable [[ptr]] StorageBuffer | ||
// CHECK: [[gep:%[^ ]+]] = OpAccessChain [[uint_ptr]] [[var]] | ||
// CHECK: [[phi:%[^ ]+]] = OpPhi [[uint_ptr]] [[gep]] [[label:%[^ ]+]] [[gep2:%[^ ]+]] [[label2:%[^ ]+]] | ||
// CHECK: [[gep2]] = OpPtrAccessChain [[uint_ptr]] [[phi]] | ||
|
||
|
||
void kernel foo(__global uint* buf, uint cst) { | ||
size_t gid = get_global_id(0); | ||
__global uint4* buf4 = buf + gid * 4 * cst; | ||
uint acc = 0; | ||
do { | ||
acc += buf4[0].x; | ||
buf4 += 4; | ||
} while (cst--); | ||
buf[gid] = acc; | ||
} |