[llvm] r341416 - [LV] First order recurrence phis should not be treated as uniform

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 6 01:17:36 PDT 2018


Merged to 7.0 in r341523.

On Wed, Sep 5, 2018 at 12:12 AM, Anna Thomas via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: annat
> Date: Tue Sep  4 15:12:23 2018
> New Revision: 341416
>
> URL: http://llvm.org/viewvc/llvm-project?rev=341416&view=rev
> Log:
> [LV] First order recurrence phis should not be treated as uniform
>
> This is fix for PR38786.
> First order recurrence phis were incorrectly treated as uniform,
> which caused them to be vectorized as uniform instructions.
>
> Patch by Ayal Zaks and Orivej Desh!
>
> Reviewed by: Anna
>
> Differential Revision: https://reviews.llvm.org/D51639
>
> Modified:
>     llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
>     llvm/trunk/test/Transforms/LoopVectorize/X86/uniform-phi.ll
>
> Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=341416&r1=341415&r2=341416&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
> +++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Tue Sep  4 15:12:23 2018
> @@ -4529,6 +4529,11 @@ void LoopVectorizationCostModel::collect
>        // isOutOfScope operands cannot be uniform instructions.
>        if (isOutOfScope(OV))
>          continue;
> +      // First order recurrence Phi's should typically be considered
> +      // non-uniform.
> +      auto *OP = dyn_cast<PHINode>(OV);
> +      if (OP && Legal->isFirstOrderRecurrence(OP))
> +        continue;
>        // If all the users of the operand are uniform, then add the
>        // operand into the uniform worklist.
>        auto *OI = cast<Instruction>(OV);
>
> Modified: llvm/trunk/test/Transforms/LoopVectorize/X86/uniform-phi.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopVectorize/X86/uniform-phi.ll?rev=341416&r1=341415&r2=341416&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/LoopVectorize/X86/uniform-phi.ll (original)
> +++ llvm/trunk/test/Transforms/LoopVectorize/X86/uniform-phi.ll Tue Sep  4 15:12:23 2018
> @@ -75,3 +75,25 @@ for.end:
>    ret i64 %retval
>  }
>
> +; CHECK-LABEL: PR38786
> +; Check that first order recurrence phis (%phi32 and %phi64) are not uniform.
> +; CHECK-NOT: LV: Found uniform instruction:   %phi
> +define void @PR38786(double* %y, double* %x, i64 %n) {
> +entry:
> +  br label %for.body
> +
> +for.body:
> +  %phi32 = phi i32 [ 0, %entry ], [ %i32next, %for.body ]
> +  %phi64 = phi i64 [ 0, %entry ], [ %i64next, %for.body ]
> +  %i32next = add i32 %phi32, 1
> +  %i64next = zext i32 %i32next to i64
> +  %xip = getelementptr inbounds double, double* %x, i64 %i64next
> +  %yip = getelementptr inbounds double, double* %y, i64 %phi64
> +  %xi = load double, double* %xip, align 8
> +  store double %xi, double* %yip, align 8
> +  %cmp = icmp slt i64 %i64next, %n
> +  br i1 %cmp, label %for.body, label %for.end
> +
> +for.end:
> +  ret void
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list