Commit 2a58675
authored
[SYCL][NVPTX] Optimize ID queries when they fit in int (#18999)
The NVPTX target was unable to properly optimize the global ID query,
despite the user specifying the -fsycl-id-queries-fit-in-int flag.
This is because, once linked, the compiler sees the global ID builtin as
(i64 add (mul (i64 zext i32 A), (i64 zext i32 B), (i64 zext i32 C))).
Despite knowing that each of A, B and C are 32-bit values, and the final
result fits in a 32-bit value, it is not legal to replace this sequence
with (i64 zext (add i32 (mul i32 A, B), C)), which is the ideal code
here.
The solution to this problem is a new opt-in 'reflection' in the NVPTX
implementation of the global ID builtin, which selects a more optimal
version. The driver enables this reflection only when the user passes
-fsycl-id-queries-fit-in-int.1 parent 1eb75c7 commit 2a58675
3 files changed
Lines changed: 35 additions & 0 deletions
File tree
- clang
- lib/Driver/ToolChains
- test/Driver
- libclc/libspirv/lib/ptx-nvidiacl/workitem
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
968 | 968 | | |
969 | 969 | | |
970 | 970 | | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
971 | 976 | | |
972 | 977 | | |
973 | 978 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
12 | 18 | | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
16 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
17 | 27 | | |
18 | 28 | | |
19 | 29 | | |
20 | 30 | | |
21 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
22 | 36 | | |
23 | 37 | | |
24 | 38 | | |
0 commit comments