[all-commits] [llvm/llvm-project] e22a59: [LV] Use lookThroughAnd with logical reductions
kmclaughlin-arm via All-commits
all-commits at lists.llvm.org
Wed Jul 21 01:56:34 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e22a59967251294ccdac6b43a06f48c1b7075240
https://github.com/llvm/llvm-project/commit/e22a59967251294ccdac6b43a06f48c1b7075240
Author: Kerry McLaughlin <kerry.mclaughlin at arm.com>
Date: 2021-07-21 (Wed, 21 Jul 2021)
Changed paths:
M llvm/lib/Analysis/IVDescriptors.cpp
M llvm/test/Transforms/LoopVectorize/reduction-inloop-pred.ll
M llvm/test/Transforms/LoopVectorize/reduction-inloop.ll
A llvm/test/Transforms/LoopVectorize/trunc-reductions.ll
Log Message:
-----------
[LV] Use lookThroughAnd with logical reductions
If a reduction Phi has a single user which `AND`s the Phi with a type mask,
`lookThroughAnd` will return the user of the Phi and the narrower type represented
by the mask. Currently this is only used for arithmetic reductions, whereas loops
containing logical reductions will create a reduction intrinsic using the widened
type, for example:
for.body:
%phi = phi i32 [ %and, %for.body ], [ 255, %entry ]
%mask = and i32 %phi, 255
%gep = getelementptr inbounds i8, i8* %ptr, i32 %iv
%load = load i8, i8* %gep
%ext = zext i8 %load to i32
%and = and i32 %mask, %ext
...
^ this will generate an and reduction intrinsic such as the following:
call i32 @llvm.vector.reduce.and.v8i32(<8 x i32>...)
The same example for an add instruction would create an intrinsic of type i8:
call i8 @llvm.vector.reduce.add.v8i8(<8 x i8>...)
This patch changes AddReductionVar to call lookThroughAnd for other integer
reductions, allowing loops similar to the example above with reductions such
as and, or & xor to vectorize.
Reviewed By: david-arm, dmgreen
Differential Revision: https://reviews.llvm.org/D105632
More information about the All-commits
mailing list