Commit a3c7d46
authored
[mlir][spirv] Implement UMod canonicalization for vector constants (#141902)
Closes #63174.
Implements this transformation pattern, which is currently only applied
to scalars, for vectors:
```
%1 = "spirv.UMod"(%0, %CONST_32) : (i32, i32) -> i32
%2 = "spirv.UMod"(%1, %CONST_4) : (i32, i32) -> i32
```
to
```
%1 = "spirv.UMod"(%0, %CONST_32) : (i32, i32) -> i32
%2 = "spirv.UMod"(%0, %CONST_4) : (i32, i32) -> i32
```
Additionally fixes and issue where patterns like this:
```
%1 = "spirv.UMod"(%0, %CONST_4) : (i32, i32) -> i32
%2 = "spirv.UMod"(%1, %CONST_32) : (i32, i32) -> i32
```
were incorrectly canonicalized to:
```
%1 = "spirv.UMod"(%0, %CONST_4) : (i32, i32) -> i32
%2 = "spirv.UMod"(%0, %CONST_32) : (i32, i32) -> i32
```
which is incorrect since `(X % A) % B` == `(X % B)` IFF A is a multiple
of B, i.e., B divides A.1 parent 02f0f5c commit a3c7d46
File tree
2 files changed
+69
-15
lines changed- mlir
- lib/Dialect/SPIRV/IR
- test/Dialect/SPIRV/Transforms
2 files changed
+69
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
329 | | - | |
330 | 329 | | |
331 | 330 | | |
332 | 331 | | |
| |||
336 | 335 | | |
337 | 336 | | |
338 | 337 | | |
339 | | - | |
340 | | - | |
| 338 | + | |
| 339 | + | |
341 | 340 | | |
342 | 341 | | |
343 | 342 | | |
344 | 343 | | |
345 | | - | |
346 | | - | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
347 | 359 | | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
| 360 | + | |
352 | 361 | | |
353 | 362 | | |
354 | 363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
967 | 967 | | |
968 | 968 | | |
969 | 969 | | |
970 | | - | |
| 970 | + | |
971 | 971 | | |
972 | | - | |
| 972 | + | |
973 | 973 | | |
974 | 974 | | |
975 | 975 | | |
976 | 976 | | |
977 | | - | |
978 | 977 | | |
979 | 978 | | |
980 | | - | |
| 979 | + | |
| 980 | + | |
981 | 981 | | |
982 | 982 | | |
983 | 983 | | |
| |||
996 | 996 | | |
997 | 997 | | |
998 | 998 | | |
999 | | - | |
| 999 | + | |
1000 | 1000 | | |
1001 | | - | |
| 1001 | + | |
1002 | 1002 | | |
1003 | 1003 | | |
1004 | 1004 | | |
| |||
1011 | 1011 | | |
1012 | 1012 | | |
1013 | 1013 | | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
1014 | 1059 | | |
1015 | 1060 | | |
1016 | 1061 | | |
| |||
0 commit comments