From c7594e48edb1b7a2ec9fc81981e539eac0604905 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 8 May 2013 18:13:06 +0000 Subject: Merging r181286: ------------------------------------------------------------------------ r181286 | arnolds | 2013-05-06 21:37:05 -0700 (Mon, 06 May 2013) | 7 lines LoopVectorize: getConsecutiveVector must respect signed arithmetic We were passing an i32 to ConstantInt::get where an i64 was needed and we must also pass the sign if we pass negatives numbers. The start index passed to getConsecutiveVector must also be signed. Should fix PR15882. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_33@181455 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/LoopVectorize/reverse_induction.ll | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 test/Transforms/LoopVectorize/reverse_induction.ll (limited to 'test/Transforms/LoopVectorize/reverse_induction.ll') diff --git a/test/Transforms/LoopVectorize/reverse_induction.ll b/test/Transforms/LoopVectorize/reverse_induction.ll new file mode 100644 index 0000000000..f43f02bc31 --- /dev/null +++ b/test/Transforms/LoopVectorize/reverse_induction.ll @@ -0,0 +1,79 @@ +; RUN: opt < %s -loop-vectorize -force-vector-unroll=2 -force-vector-width=4 -S | FileCheck %s + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" + +; Make sure consecutive vector generates correct negative indices. +; PR15882 + +; CHECK: reverse_induction_i64 +; CHECK: add <4 x i64> %[[SPLAT:.*]], +; CHECK: add <4 x i64> %[[SPLAT]], + +define i32 @reverse_induction_i64(i64 %startval, i32 * %ptr) { +entry: + br label %for.body + +for.body: + %add.i7 = phi i64 [ %startval, %entry ], [ %add.i, %for.body ] + %i.06 = phi i32 [ 0, %entry ], [ %inc4, %for.body ] + %redux5 = phi i32 [ 0, %entry ], [ %inc.redux, %for.body ] + %add.i = add i64 %add.i7, -1 + %kind_.i = getelementptr inbounds i32* %ptr, i64 %add.i + %tmp.i1 = load i32* %kind_.i, align 4 + %inc.redux = add i32 %tmp.i1, %redux5 + %inc4 = add i32 %i.06, 1 + %exitcond = icmp ne i32 %inc4, 1024 + br i1 %exitcond, label %for.body, label %loopend + +loopend: + ret i32 %inc.redux +} + +; CHECK: reverse_induction_i128 +; CHECK: add <4 x i128> %[[SPLAT:.*]], +; CHECK: add <4 x i128> %[[SPLAT]], +define i32 @reverse_induction_i128(i128 %startval, i32 * %ptr) { +entry: + br label %for.body + +for.body: + %add.i7 = phi i128 [ %startval, %entry ], [ %add.i, %for.body ] + %i.06 = phi i32 [ 0, %entry ], [ %inc4, %for.body ] + %redux5 = phi i32 [ 0, %entry ], [ %inc.redux, %for.body ] + %add.i = add i128 %add.i7, -1 + %kind_.i = getelementptr inbounds i32* %ptr, i128 %add.i + %tmp.i1 = load i32* %kind_.i, align 4 + %inc.redux = add i32 %tmp.i1, %redux5 + %inc4 = add i32 %i.06, 1 + %exitcond = icmp ne i32 %inc4, 1024 + br i1 %exitcond, label %for.body, label %loopend + +loopend: + ret i32 %inc.redux +} + +; CHECK: reverse_induction_i16 +; CHECK: add <4 x i16> %[[SPLAT:.*]], +; CHECK: add <4 x i16> %[[SPLAT]], + +define i32 @reverse_induction_i16(i16 %startval, i32 * %ptr) { +entry: + br label %for.body + +for.body: + %add.i7 = phi i16 [ %startval, %entry ], [ %add.i, %for.body ] + %i.06 = phi i32 [ 0, %entry ], [ %inc4, %for.body ] + %redux5 = phi i32 [ 0, %entry ], [ %inc.redux, %for.body ] + %add.i = add i16 %add.i7, -1 + %kind_.i = getelementptr inbounds i32* %ptr, i16 %add.i + %tmp.i1 = load i32* %kind_.i, align 4 + %inc.redux = add i32 %tmp.i1, %redux5 + %inc4 = add i32 %i.06, 1 + %exitcond = icmp ne i32 %inc4, 1024 + br i1 %exitcond, label %for.body, label %loopend + +loopend: + ret i32 %inc.redux +} + + -- cgit v1.2.3-70-g09d2