[llvm] r245632 - [LoopVectorize] Propagate 'nontemporal' attribute into vectorized instructions.
Michael Zolotukhin via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 20 16:29:21 PDT 2015
Hi Philip,
On Aug 20, 2015, at 4:22 PM, Philip Reames <listmail at philipreames.com> wrote:
>
> Michael,
>
> Can you add a test case that shows two adjacent loads one with !nontemporal, one without? I want to make sure we get that correct (i.e. not marking the result non-temporary if vectorized). Doing this as a test case would make it obvious to future readers as well.
>
> (Same for the SLP patch btw.)
It’s not applicable to loop-vectorizer, because there we have a single original load, and then just replicate it N times (we don’t emit IR for this, but that’s the idea). Thus, all loads that we’re going to combine have the same ‘!nontemporal’ attribute. But that makes sense for the SLP-vectorization, I’ll add corresponding test case shortly.
Thanks,
Michael
>
> Philip
>
> On 08/20/2015 03:27 PM, Michael Zolotukhin via llvm-commits wrote:
>> Author: mzolotukhin
>> Date: Thu Aug 20 17:27:38 2015
>> New Revision: 245632
>>
>> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D245632-26view-3Drev&d=BQICaQ&c=eEvniauFctOgLOKGJOplqw&r=ygVmcuuQ1MUhRUoJm-IgPtgjmvM0byfjlHDg99vufEI&m=ziQkFxLF161LcWw4qZBl9GRB3K3jsTax2u_B8gbGZO4&s=a__wFv_hZ8xcOmDnbHb2PqziHvdq184-iwQM3ThtJLE&e= Log:
>> [LoopVectorize] Propagate 'nontemporal' attribute into vectorized instructions.
>>
>> Added:
>> llvm/trunk/test/Transforms/LoopVectorize/nontemporal.ll
>> Modified:
>> llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
>>
>> Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
>> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_Transforms_Vectorize_LoopVectorize.cpp-3Frev-3D245632-26r1-3D245631-26r2-3D245632-26view-3Ddiff&d=BQICaQ&c=eEvniauFctOgLOKGJOplqw&r=ygVmcuuQ1MUhRUoJm-IgPtgjmvM0byfjlHDg99vufEI&m=ziQkFxLF161LcWw4qZBl9GRB3K3jsTax2u_B8gbGZO4&s=0vhvZxOz3ui9DNSgD8uCCSfzjGZVKszXLDxorzX48Qo&e= ==============================================================================
>> --- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
>> +++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Thu Aug 20 17:27:38 2015
>> @@ -552,7 +552,8 @@ static void propagateMetadata(Instructio
>> if (Kind != LLVMContext::MD_tbaa &&
>> Kind != LLVMContext::MD_alias_scope &&
>> Kind != LLVMContext::MD_noalias &&
>> - Kind != LLVMContext::MD_fpmath)
>> + Kind != LLVMContext::MD_fpmath &&
>> + Kind != LLVMContext::MD_nontemporal)
>> continue;
>> To->setMetadata(Kind, M.second);
>>
>> Added: llvm/trunk/test/Transforms/LoopVectorize/nontemporal.ll
>> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_Transforms_LoopVectorize_nontemporal.ll-3Frev-3D245632-26view-3Dauto&d=BQICaQ&c=eEvniauFctOgLOKGJOplqw&r=ygVmcuuQ1MUhRUoJm-IgPtgjmvM0byfjlHDg99vufEI&m=ziQkFxLF161LcWw4qZBl9GRB3K3jsTax2u_B8gbGZO4&s=YxoAnzwN86Ff4IuXHfmj7vHpPLnP8Ht0scSjKTibdbg&e= ==============================================================================
>> --- llvm/trunk/test/Transforms/LoopVectorize/nontemporal.ll (added)
>> +++ llvm/trunk/test/Transforms/LoopVectorize/nontemporal.ll Thu Aug 20 17:27:38 2015
>> @@ -0,0 +1,47 @@
>> +; RUN: opt < %s -loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -instcombine -S | FileCheck %s
>> +
>> +target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
>> +target triple = "arm64-apple-ios5.0.0"
>> +
>> +; CHECK-LABEL: @foo(
>> +define void @foo(float* noalias %a, float* noalias %b, float* noalias %c, i32 %N) {
>> +entry:
>> + %cmp.4 = icmp sgt i32 %N, 0
>> + br i1 %cmp.4, label %for.body.preheader, label %for.end
>> +
>> +for.body.preheader: ; preds = %entry
>> + br label %for.body
>> +
>> +for.body: ; preds = %for.body.preheader, %for.body
>> + %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
>> +
>> +; Check that we don't lose !nontemporal hint when vectorizing loads.
>> +; CHECK: %wide.load{{[0-9]*}} = load <4 x float>, <4 x float>* %{{[0-9]+}}, align 4, !nontemporal !0
>> + %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
>> + %0 = load float, float* %arrayidx, align 4, !nontemporal !0
>> +
>> +; Check that we don't introduce !nontemporal hint when the original scalar loads didn't have it.
>> +; CHECK: %wide.load{{[0-9]+}} = load <4 x float>, <4 x float>* %{{[0-9]+}}, align 4{{$}}
>> + %arrayidx2 = getelementptr inbounds float, float* %c, i64 %indvars.iv
>> + %1 = load float, float* %arrayidx2, align 4
>> + %add = fadd float %0, %1
>> +
>> +; Check that we don't lose !nontemporal hint when vectorizing stores.
>> +; CHECK: store <4 x float> %{{[0-9]+}}, <4 x float>* %{{[0-9]+}}, align 4, !nontemporal !0
>> + %arrayidx4 = getelementptr inbounds float, float* %a, i64 %indvars.iv
>> + store float %add, float* %arrayidx4, align 4, !nontemporal !0
>> +
>> + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
>> + %lftr.wideiv = trunc i64 %indvars.iv.next to i32
>> + %exitcond = icmp eq i32 %lftr.wideiv, %N
>> + br i1 %exitcond, label %for.end.loopexit, label %for.body
>> +
>> +for.end.loopexit: ; preds = %for.body
>> + br label %for.end
>> +
>> +for.end: ; preds = %for.end.loopexit, %entry
>> +; CHECK: ret void
>> + ret void
>> +}
>> +
>> +!0 = !{i32 1}
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Dcommits&d=BQICaQ&c=eEvniauFctOgLOKGJOplqw&r=ygVmcuuQ1MUhRUoJm-IgPtgjmvM0byfjlHDg99vufEI&m=ziQkFxLF161LcWw4qZBl9GRB3K3jsTax2u_B8gbGZO4&s=Z0hqA-nDtL8T92bt6aae0esKfzBixkV1CZ3QVwSGaX8&e=
>
More information about the llvm-commits
mailing list