1; RUN: opt -S -basic-aa -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" 4 5@uf = common global [100 x i32] zeroinitializer, align 16 6@xi = common global [100 x i32] zeroinitializer, align 16 7@q = common global [100 x i32] zeroinitializer, align 16 8 9; PR16455 10 11 12; Due to a bug in the way we handled reverse induction stores we would generate 13; a shuffle too many. 14 15define void @t() { 16entry: 17 br label %for.body 18 19; CHECK-LABEL: @t( 20; CHECK: vector.body: 21; CHECK: [[VAR1:%[a-zA-Z0-9.]+]] = load <4 x i32> 22; CHECK: [[VAR2:%[a-zA-Z0-9.]+]] = load <4 x i32> 23; CHECK: [[VAR3:%[a-zA-Z0-9]+]] = add nsw <4 x i32> [[VAR2]], [[VAR1]] 24; CHECK: store <4 x i32> [[VAR3]] 25; CHECK: [[VAR4:%[a-zA-Z0-9.]+]] = load <4 x i32> 26; CHECK: add nsw <4 x i32> [[VAR3]], [[VAR4]] 27; CHECK-NOT: shufflevector 28 29for.body: 30 %indvars.iv = phi i64 [ 93, %entry ], [ %indvars.iv.next, %for.body ] 31 %0 = add i64 %indvars.iv, 1 32 %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* @uf, i64 0, i64 %0 33 %arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* @xi, i64 0, i64 %0 34 %1 = load i32, i32* %arrayidx3, align 4 35 %2 = load i32, i32* %arrayidx, align 4 36 %add4 = add nsw i32 %2, %1 37 store i32 %add4, i32* %arrayidx, align 4 38 %arrayidx7 = getelementptr inbounds [100 x i32], [100 x i32]* @q, i64 0, i64 %0 39 %3 = load i32, i32* %arrayidx7, align 4 40 %add8 = add nsw i32 %add4, %3 41 store i32 %add8, i32* %arrayidx, align 4 42 %indvars.iv.next = add i64 %indvars.iv, -1 43 %4 = trunc i64 %indvars.iv.next to i32 44 %cmp = icmp ugt i32 %4, 2 45 br i1 %cmp, label %for.body, label %for.end 46 47for.end: 48 ret void 49} 50