| Issue |
169058
|
| Summary |
wasm: `i8x16.swizzle` with a constant value should be optimized to `i8x16.shuffle`
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
valadaptive
|
A SIMD variable permute (like `i8x16.swizzle`) should be optimizable to a constant permute (like `i8x16.shuffle`) if the input is constant. This type of optimization is already performed for x86 vector operations, but not for WebAssembly vector operations.
This optimization is particularly useful for architecture-generic SIMD, where exposing constant permutes might not be possible depending on the type system.
Take a look at this example code (also on https://godbolt.org/z/6esax48Kr):
```c
#include <wasm_simd128.h>
v128_t reverse(v128_t n) {
v128_t indices = wasm_i8x16_make(
15,
14,
13,
12,
11,
10,
9,
8,
7,
6,
5,
4,
3,
2,
1,
0
);
return wasm_i8x16_swizzle(n, indices);
}
```
I would expect this code to be optimized to:
```asm
reverse:
local.get 0
local.get 0
i8x16.shuffle 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
end_function
```
But instead, we get:
```asm
reverse:
local.get 0
v128.const 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
i8x16.swizzle
end_function
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs