1 ; RUN: opt -mtriple=x86_64-apple-darwin -mcpu=core2 -loop-vectorize -dce -instcombine -S < %s | FileCheck %s 2 3 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" 4 5 @B = common global [1024 x i32] zeroinitializer, align 16 6 @A = common global [1024 x i32] zeroinitializer, align 16 7 8 ; We use to not vectorize this loop because the shift was deemed to expensive. 9 ; Now that we differentiate shift cost base on the operand value kind, we will 10 ; vectorize this loop. 11 ; CHECK: ashr <4 x i32> 12 define void @f() { 13 entry: 14 br label %for.body 15 16 for.body: 17 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 18 %arrayidx = getelementptr inbounds [1024 x i32], [1024 x i32]* @B, i64 0, i64 %indvars.iv 19 %0 = load i32, i32* %arrayidx, align 4 20 %shl = ashr i32 %0, 3 21 %arrayidx2 = getelementptr inbounds [1024 x i32], [1024 x i32]* @A, i64 0, i64 %indvars.iv 22 store i32 %shl, i32* %arrayidx2, align 4 23 %indvars.iv.next = add i64 %indvars.iv, 1 24 %lftr.wideiv = trunc i64 %indvars.iv.next to i32 25 %exitcond = icmp eq i32 %lftr.wideiv, 1024 26 br i1 %exitcond, label %for.end, label %for.body 27 28 for.end: 29 ret void 30 } 31