From 433cb1dfe31a85e5e39743032a18c96bf12ce955 Mon Sep 17 00:00:00 2001 From: Matthew Simpson Date: Wed, 6 Jul 2016 14:26:59 +0000 Subject: [LV] Don't widen trivial induction variables We currently always vectorize induction variables. However, if an induction variable is only used for counting loop iterations or computing addresses with getelementptr instructions, we don't need to do this. Vectorizing these trivial induction variables can create vector code that is difficult to simplify later on. This is especially true when the unroll factor is greater than one, and we create vector arithmetic when computing step vectors. With this patch, we check if an induction variable is only used for counting iterations or computing addresses, and if so, scalarize the arithmetic when computing step vectors instead. This allows for greater simplification. This patch addresses the suboptimal pointer arithmetic sequence seen in PR27881. Reference: https://llvm.org/bugs/show_bug.cgi?id=27881 Differential Revision: http://reviews.llvm.org/D21620 llvm-svn: 274627 --- llvm/test/Transforms/LoopVectorize/gep_with_bitcast.ll | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'llvm/test/Transforms/LoopVectorize/gep_with_bitcast.ll') diff --git a/llvm/test/Transforms/LoopVectorize/gep_with_bitcast.ll b/llvm/test/Transforms/LoopVectorize/gep_with_bitcast.ll index fb12e172f54..e73b6eacbe1 100644 --- a/llvm/test/Transforms/LoopVectorize/gep_with_bitcast.ll +++ b/llvm/test/Transforms/LoopVectorize/gep_with_bitcast.ll @@ -12,11 +12,11 @@ target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128" ; CHECK-LABEL: @foo ; CHECK: vector.body -; CHECK: %0 = phi -; CHECK: %2 = getelementptr inbounds double*, double** %in, i64 %0 -; CHECK: %3 = bitcast double** %2 to <4 x i64>* -; CHECK: %wide.load = load <4 x i64>, <4 x i64>* %3, align 8 -; CHECK: %4 = icmp eq <4 x i64> %wide.load, zeroinitializer +; CHECK: %[[IV:.+]] = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ] +; CHECK: %[[v0:.+]] = getelementptr inbounds double*, double** %in, i64 %[[IV]] +; CHECK: %[[v1:.+]] = bitcast double** %[[v0]] to <4 x i64>* +; CHECK: %wide.load = load <4 x i64>, <4 x i64>* %[[v1]], align 8 +; CHECK: icmp eq <4 x i64> %wide.load, zeroinitializer ; CHECK: br i1 define void @foo(double** noalias nocapture readonly %in, double** noalias nocapture readnone %out, i8* noalias nocapture %res) #0 { -- cgit v1.2.3