| Issue |
79094
|
| Summary |
integers bitcasted to vectors then coerced to vectors of larger integers needs optimization
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Validark
|
This issue was originally posted at https://github.com/ziglang/zig/issues/18631
### Steps to Reproduce and Observed Behavior
See [godbolt](https://zig.godbolt.org/z/axKsvfv38)
This code results in horrible assembly:
```zig
fn foo(x: u32) @Vector(8, u32) {
return @as(@Vector(8, u4), @bitCast(x));
}
```
### Expected Behavior
Should be compiled to the same thing as:
```zig
fn bar(x: u32) @Vector(8, u32) {
const vec: @Vector(8, u32) = @splat(x);
const vec2 = std.simd.iota(u5, 8) << @splat(2);
return (vec >> vec2) & @as(@Vector(8, u32), @splat(0xF));
}
```
The latter of which compiles like so on the latest x86_64:
```asm
.LCPI1_0:
.long 0
.long 4
.long 8
.long 12
.long 16
.long 20
.long 24
.long 28
.LCPI1_1:
.long 15
bar:
vpbroadcastd ymm0, edi
vpsrlvd ymm0, ymm0, ymmword ptr [rip + .LCPI1_0]
vpandd ymm0, ymm0, dword ptr [rip + .LCPI1_1]{1to8}
ret
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs