Commit 1500f12
Junda Liu
[SPIR-V] Fix OpBitFieldExtract emulation for unsigned integer (microsoft#7167)
For an unsigned integer, we should OpShiftRightLogical instead of
OpShiftRightArithmetic. Otherwise the value may be extended incorrectly.
For example:
```
struct S {
uint16_t m1 : 8;
uint16_t m2 : 8;
};
void main() {
S s;
s.m1 = 0xff;
s.m2 = 0xff;
uint16_t result = s.m1;
}
```
If we do OpShiftRightArithmetic here, the result will be 0xffff.1 parent 2eeb47e commit 1500f12
File tree
2 files changed
+12
-8
lines changed- tools/clang
- lib/SPIRV
- test/CodeGenSPIRV
2 files changed
+12
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
978 | 978 | | |
979 | 979 | | |
980 | 980 | | |
981 | | - | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
982 | 986 | | |
983 | 987 | | |
984 | | - | |
985 | | - | |
| 988 | + | |
| 989 | + | |
986 | 990 | | |
987 | 991 | | |
988 | 992 | | |
| |||
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
0 commit comments