《20.SpacemiT-Introduce the implementation of LLVM Loop Vectorizer.pdf》由会员分享,可在线阅读,更多相关《20.SpacemiT-Introduce the implementation of LLVM Loop Vectorizer.pdf(20页珍藏版)》请在三个皮匠报告上搜索。
1、进迭时空资料|SpacemiT All Rights Reserved1wengliqin,CompilersSpacemiTzhuangqiubin,CompilersSpacemiTIntroduce the Implementation of LLVM Loop Vectorizer进迭时空资料|SpacemiT All Rights Reserved2Loop VectorizerThe Loop Vectorizer widens instructions in loops to operate on multiple consecutive iterations进迭时空资料|Spa
2、cemiT All Rights Reserved3Loop VectorizerCheck if the current loop can be vectorized and verify its legalityIf the legality check passes,use the cost model to analyze whether vectorization is beneficial.If the vectorized code is profitable,complete the conversion from scalar to vector code and updat
3、e the curent loops control flow.control flow analysisInstruction widenMemory access analysis进迭时空资料|SpacemiT All Rights Reserved4Vectorization Plan in the Loop VectorizerVPlan is an explicit model for describing vectorization candidates.It serves two main purposes:optimizing candidates by reliably es
4、timating their cost,and performing their final translation into LLVM IR.Simplfied the analysis and transformsVectorize loops better,and vectorize more loopsMore accurate in cost model for RecipeCostvector.phy:.vector.body:%index=phi i64 0,%vector.ph,%index.next,%vector.body%evl.based.iv=phi i64 0,%v
5、ector.ph,%index.evl.next,%vector.body%avl=sub i64%wide.trip.count,%evl.based.iv%5=call i32 llvm.experimental.get.vector.length.i64(i64%avl,i32 4,i1 true)%6=getelementptr inbounds nuw i32,ptr%A,i64%evl.based.iv%7=getelementptr inbounds nuw i32,ptr%6,i32 0%vp.op.load=call llvm.vp.load.nxv4i32.p0(ptr%7
6、,splat(i1 true),i32%5)%8=add nsw%vp.op.load,splat(i32 1)call void llvm.vp.store.nxv4i32.p0(%8,ptr%7,splat(i1 true),i32%5)br i1%10,label%middle.block,label%vector.body.middle.block .entry:.for.body:%iv=phi i64 0,%for.body.preheader,%iv.next,%for.body%gep=getelementptr inbounds nuw i32,ptr%A,i64%iv%0=