Issue |
132922
|
Summary |
[InstCombine] Scalable splats don't have trunc constant folded
|
Labels |
llvm:instcombine
|
Assignees |
|
Reporter |
lukel97
|
https://godbolt.org/z/WGd66165o
```llvm
define <vscale x 1 x i8> @f() {
%1 = trunc <vscale x 1 x i64> splat (i64 1) to <vscale x 1 x i8>
ret <vscale x 1 x i8> %1
}
define <2 x i8> @g() {
%1 = trunc <2 x i64> splat (i64 1) to <2 x i8>
ret <2 x i8> %1
}
```
With `opt -p instcombine`, only the fixed-length vector splat has the truncate constant folded
```
define <vscale x 1 x i8> @f() {
ret <vscale x 1 x i8> trunc (<vscale x 1 x i64> splat (i64 1) to <vscale x 1 x i8>)
}
define <2 x i8> @g() {
ret <2 x i8> splat (i8 1)
}
```
The same thing also happens for ConstantExprs, but the fixed-length splat seems to be already folded before it even reaches InstCombine. I think it might be happening in the parser.
```llvm
define <vscale x 1 x i8> @h(<vscale x 1 x i8> %x) {
%1 = and <vscale x 1 x i8> %x, trunc (<vscale x 1 x i64> splat (i64 1) to <vscale x 1 x i8>)
ret <vscale x 1 x i8> %1
}
define <2 x i8> @i(<2 x i8> %x) {
%1 = and <2 x i8> %x, trunc (<2 x i64> splat (i64 1) to <2 x i8>)
ret <2 x i8> %1
}
```
After `opt` (no passes)
```llvm
define <vscale x 1 x i8> @h(<vscale x 1 x i8> %x) {
%1 = and <vscale x 1 x i8> %x, trunc (<vscale x 1 x i64> splat (i64 1) to <vscale x 1 x i8>)
ret <vscale x 1 x i8> %1
}
define <2 x i8> @i(<2 x i8> %x) {
%1 = and <2 x i8> %x, splat (i8 1)
ret <2 x i8> %1
}
```
I noticed this when trying to match some patterns for #132245
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs