[PATCH][X86] Fix missed selection of non-temporal store of zero vector (PR19370).

Quentin Colombet qcolombet at apple.com
Thu Oct 16 11:49:15 PDT 2014


Hi Andrea,

The general direction looks good, just a couple of questions:
Since we are matching integer types, shouldn’t we use the integer variant: MOVNTD?

Moreover, wouldn’t it make sense to have a more general pattern for this?
I.e., we could use VR128 instead of immAllZerosV, couldn’t we?

Thanks,
-Quentin

> On Oct 16, 2014, at 10:41 AM, Andrea Di Biagio <andrea.dibiagio at gmail.com> wrote:
> 
> Hi,
> 
> This is a fix for PR19370.
> Currently the x86 backend wrongly selects a a normal vector store
> instead of a non-temporal store if the value to store is a vector of
> all zeros.
> 
> Small reproducible:
> 
> ;;
> define void @test(<4 x float>* %dst) {
>  store <4 x float> zeroinitializer, <4 x float>* %dst, align 16,
> !nontemporal !1
>  ret void
> }
> 
> !1 = metadata !{i32 1}
> ;;
> 
> llc (-mtriple=x86_64-unknown-unknown -mcpu=corei7-avx) generates:
>  vxorps  %xmm0, %xmm0, %xmm0
>  vmovaps %xmm0, (%rdi)
>  retq
> 
> Instead, llc should generate:
>  vxorps  %xmm0, %xmm0, %xmm0
>  vmovntps  %xmm0, (%rdi)
>  retq
> 
> In this example, the vector of all zeros is legalized to a zero vector
> of type v4i32.
> However, ISel doesn't have a rule to select a MOVNTPSmr when the
> source is not a vector of float elements. So, it eventually (wrongly)
> falls back to selecting a normal store.
> 
> This patch fixes the problem adding extra ISel patterns to cover that
> particular corner case.
> 
> Please let me know if ok to commit.
> 
> Thanks!
> Andrea
> <patch-nontemporal.diff>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141016/2c6ca253/attachment.html>


More information about the llvm-commits mailing list