<div dir="ltr"><div>Just out of curiosity,</div><div>would it perhaps make sense to canonicalize this to a masked store?</div><div><br></div><div>Nemanja<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 26, 2019 at 10:59 PM Qiu Chaofan via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> I may be missing something obvious, but what is `vector` defined as here? Can you provide a buildable example?<br>
<br>
Sorry, I should provide a cross-platform version using vector<br>
extension of frontend :) `vector int` is a vector extension on<br>
PowerPC, which is enabled if you set target to PowerPC platforms.<br>
Example below should be successfully compiled in any platform:<br>
<br>
    typedef float v4sf __attribute__ ((vector_size(16)));<br>
<br>
    void foo(v4sf *a) {<br>
      (*a)[0] = 1;<br>
      (*a)[3] = 2;<br>
    }<br>
<br>
And we can get the IR mentioned before:<br>
<br>
    %0 = load <4 x float>, <4 x float>* %a, align 16<br>
    %vecins1 = shufflevector <4 x float> <float 1.000000e+00, float<br>
undef, float undef, float 2.000000e+00>, <4 x float> %0, <4 x i32><br>
<i32 0, i32 5, i32 6, i32 3><br>
    store <4 x float> %vecins1, <4 x float>* %a, align 16<br>
<br>
Regards,<br>
Qiu Chaofan<br>
<br>
<br>
Florian Hahn <<a href="mailto:florian_hahn@apple.com" target="_blank">florian_hahn@apple.com</a>> 于2019年9月26日周四 下午7:15写道:<br>
><br>
> Hi<br>
><br>
> > On Sep 26, 2019, at 10:53, Qiu Chaofan via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> ><br>
> > Hi there,<br>
> ><br>
> > I notice that LLVM seems to always generate vector instructions for<br>
> > vector operations in C, even it's just simple stores:<br>
> ><br>
> > void foo(vector int* c) {<br>
> >  (*c)[0] = 1;<br>
> >  (*c)[1] = 2;<br>
> > }<br>
> ><br>
><br>
> I may be missing something obvious, but what is `vector` defined as here? Can you provide a buildable example?<br>
><br>
> > %0 = load <4 x i32>, <4 x i32>* %c, align 16<br>
> > %vecins1 = shufflevector <4 x i32> <i32 1, i32 2, i32 undef, i32<br>
> > undef>, <4 x i32> %0, <4 x i32> <i32 0, i32 1, i32 6, i32 7><br>
> > store <4 x i32> %vecins1, <4 x i32>* %c, align 16<br>
> ><br>
><br>
> 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?<br>
><br>
> Cheers,<br>
> Florian<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>