Commit 9ee056e
authored
[SPIR-V] Remove bitcast from float->int conversion (microsoft#6533)
OpConvertFToU and FToS convert numerically from floating point to
integer, with rounding toward 0.0, matching the defined behavior of HLSL
without any need for an initial bitwidth conversion from floating point
to floating point, which can result in incorrect rounding behavior (see
microsoft#6501).
Note that behavior is undefined if the target type is not wide enough to
hold the converted value, however this was also true with an initial
bitcast (because an N-bit FP can hold values outside the range of an
N-bit int), and I can't come up with any case where an intial truncation
would result in correct defined behavior where this straight conversion
would be undefined since the precision will inevitably be lost anyways.
Fixes microsoft#65011 parent dda80a9 commit 9ee056e
File tree
4 files changed
+15
-29
lines changed- tools/clang
- lib/SPIRV
- test/CodeGenSPIRV
4 files changed
+15
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8233 | 8233 | | |
8234 | 8234 | | |
8235 | 8235 | | |
8236 | | - | |
8237 | | - | |
8238 | | - | |
8239 | 8236 | | |
8240 | 8237 | | |
8241 | 8238 | | |
8242 | | - | |
| 8239 | + | |
| 8240 | + | |
| 8241 | + | |
8243 | 8242 | | |
8244 | 8243 | | |
8245 | | - | |
8246 | | - | |
8247 | 8244 | | |
8248 | 8245 | | |
8249 | 8246 | | |
| |||
8310 | 8307 | | |
8311 | 8308 | | |
8312 | 8309 | | |
| 8310 | + | |
8313 | 8311 | | |
8314 | 8312 | | |
8315 | 8313 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
| 44 | + | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
53 | | - | |
54 | | - | |
| 52 | + | |
55 | 53 | | |
56 | 54 | | |
57 | 55 | | |
| |||
95 | 93 | | |
96 | 94 | | |
97 | 95 | | |
98 | | - | |
99 | | - | |
| 96 | + | |
100 | 97 | | |
101 | 98 | | |
102 | 99 | | |
103 | 100 | | |
104 | 101 | | |
105 | 102 | | |
106 | 103 | | |
107 | | - | |
108 | | - | |
| 104 | + | |
109 | 105 | | |
110 | 106 | | |
111 | 107 | | |
112 | 108 | | |
113 | 109 | | |
114 | 110 | | |
115 | 111 | | |
116 | | - | |
117 | | - | |
| 112 | + | |
118 | 113 | | |
119 | 114 | | |
120 | 115 | | |
121 | | - | |
122 | | - | |
| 116 | + | |
123 | 117 | | |
124 | 118 | | |
125 | 119 | | |
| |||
Lines changed: 4 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 29 | + | |
| 30 | + | |
33 | 31 | | |
34 | 32 | | |
35 | 33 | | |
| |||
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 39 | + | |
| 40 | + | |
45 | 41 | | |
46 | 42 | | |
47 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | 81 | | |
83 | 82 | | |
84 | 83 | | |
| |||
106 | 105 | | |
107 | 106 | | |
108 | 107 | | |
109 | | - | |
110 | | - | |
| 108 | + | |
111 | 109 | | |
112 | 110 | | |
113 | 111 | | |
| |||
0 commit comments