[llvm-dev] Opportunity to split store of shuffled vector.
Florian Hahn via llvm-dev
llvm-dev at lists.llvm.org
Thu Sep 26 04:15:21 PDT 2019
Hi
> On Sep 26, 2019, at 10:53, Qiu Chaofan via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
> Hi there,
>
> I notice that LLVM seems to always generate vector instructions for
> vector operations in C, even it's just simple stores:
>
> void foo(vector int* c) {
> (*c)[0] = 1;
> (*c)[1] = 2;
> }
>
I may be missing something obvious, but what is `vector` defined as here? Can you provide a buildable example?
> %0 = load <4 x i32>, <4 x i32>* %c, align 16
> %vecins1 = shufflevector <4 x i32> <i32 1, i32 2, i32 undef, i32
> undef>, <4 x i32> %0, <4 x i32> <i32 0, i32 1, i32 6, i32 7>
> store <4 x i32> %vecins1, <4 x i32>* %c, align 16
>
For some reason, we load 4 elements from %c and write the last 2 elements back unchanged. This causes sub-optimal codegen here. We could do a better job at dropping the writes of unchanged elements. But from the original code, it is not immediately obvious to me why we generate them in the first place. Maybe we could avoid generating them?
Cheers,
Florian
More information about the llvm-dev
mailing list