-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[AArch64] Bad codegen for widen followed by vdupq_n_* #128349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@llvm/issue-subscribers-backend-aarch64 Author: Nikita Popov (nikic)
From https://github.com/rust-lang/rust/issues/137407:
VectorCombine(+InstCombine) perform this transform (https://llvm.godbolt.org/z/veW5oG6Gx): define void @<!-- -->src(ptr %ptr, i16 %x) {
%ext = zext i16 %x to i32
%ins = insertelement <1 x i32> poison, i32 %ext, i64 0
%shuf = shufflevector <1 x i32> %ins, <1 x i32> poison, <4 x i32> zeroinitializer
%bc = bitcast <4 x i32> %shuf to <8 x i16>
%add = add <8 x i16> %bc, <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
store <8 x i16> %add, ptr %ptr, align 16
ret void
}
define void @<!-- -->tgt(ptr %ptr, i16 %x) {
%1 = insertelement <2 x i16> <i16 poison, i16 0>, i16 %x, i64 0
%bc = shufflevector <2 x i16> %1, <2 x i16> poison, <8 x i32> <i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1>
%add = add <8 x i16> %bc, splat (i16 1)
store <8 x i16> %add, ptr %ptr, align 16
ret void
} Resulting in this codegen (https://llvm.godbolt.org/z/Px83GGq7Y):
The dup has been replaced by element-wise movs. |
Do you know where the Shuffles that change-type have never been very well supported in the cost-model in the past, they are getting better over time. |
It's how rust lowers |
Oh, that's a good point. I didn't realize that Rust uses this weird pattern to generate a vector splat. |
The cost model in the backend is also a little higher than it should be for these shuffles. It is treating it as something that needs legalization into multiple vectors, not something that would be padded. |
Uh oh!
There was an error while loading. Please reload this page.
From rust-lang/rust#137407:
VectorCombine(+InstCombine) perform this transform (https://llvm.godbolt.org/z/veW5oG6Gx):
Resulting in this codegen (https://llvm.godbolt.org/z/Px83GGq7Y):
The dup has been replaced by element-wise movs.
The text was updated successfully, but these errors were encountered: