1; RUN: opt < %s -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -S | FileCheck %s 2 3target 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" 4target triple = "x86_64-apple-macosx10.8.0" 5 6; Make sure that the reverse iterators are calculated using 64bit arithmetic, not 32. 7; 8; int foo(int n, int *A) { 9; int sum; 10; for (int i=n; i > 0; i--) 11; sum += A[i*2]; 12; return sum; 13; } 14; 15 16;CHECK-LABEL: @foo( 17;CHECK: <i64 0, i64 -1, i64 -2, i64 -3> 18;CHECK: ret 19define i32 @foo(i32 %n, i32* nocapture %A) { 20 %1 = icmp sgt i32 %n, 0 21 br i1 %1, label %.lr.ph, label %._crit_edge 22 23.lr.ph: ; preds = %0 24 %2 = sext i32 %n to i64 25 br label %3 26 27; <label>:3 ; preds = %.lr.ph, %3 28 %indvars.iv = phi i64 [ %2, %.lr.ph ], [ %indvars.iv.next, %3 ] 29 %sum.01 = phi i32 [ undef, %.lr.ph ], [ %9, %3 ] 30 %4 = trunc i64 %indvars.iv to i32 31 %5 = shl nsw i32 %4, 1 32 %6 = sext i32 %5 to i64 33 %7 = getelementptr inbounds i32, i32* %A, i64 %6 34 %8 = load i32, i32* %7, align 4 35 %9 = add nsw i32 %8, %sum.01 36 %indvars.iv.next = add i64 %indvars.iv, -1 37 %10 = trunc i64 %indvars.iv.next to i32 38 %11 = icmp sgt i32 %10, 0 39 br i1 %11, label %3, label %._crit_edge 40 41._crit_edge: ; preds = %3, %0 42 %sum.0.lcssa = phi i32 [ undef, %0 ], [ %9, %3 ] 43 ret i32 %sum.0.lcssa 44} 45 46