1 ; RUN: opt < %s -basicaa -slp-vectorizer -dce -S -mtriple=i386-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s 2 3 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32-S128" 4 target triple = "i386-apple-macosx10.9.0" 5 6 ;int foo(double *A, int k) { 7 ; double A0; 8 ; double A1; 9 ; if (k) { 10 ; A0 = 3; 11 ; A1 = 5; 12 ; } else { 13 ; A0 = A[10]; 14 ; A1 = A[11]; 15 ; } 16 ; A[0] = A0; 17 ; A[1] = A1; 18 ;} 19 20 21 ;CHECK: i32 @foo 22 ;CHECK: load <2 x double> 23 ;CHECK: phi <2 x double> 24 ;CHECK: store <2 x double> 25 ;CHECK: ret i32 undef 26 define i32 @foo(double* nocapture %A, i32 %k) { 27 entry: 28 %tobool = icmp eq i32 %k, 0 29 br i1 %tobool, label %if.else, label %if.end 30 31 if.else: ; preds = %entry 32 %arrayidx = getelementptr inbounds double* %A, i64 10 33 %0 = load double* %arrayidx, align 8 34 %arrayidx1 = getelementptr inbounds double* %A, i64 11 35 %1 = load double* %arrayidx1, align 8 36 br label %if.end 37 38 if.end: ; preds = %entry, %if.else 39 %A0.0 = phi double [ %0, %if.else ], [ 3.000000e+00, %entry ] 40 %A1.0 = phi double [ %1, %if.else ], [ 5.000000e+00, %entry ] 41 store double %A0.0, double* %A, align 8 42 %arrayidx3 = getelementptr inbounds double* %A, i64 1 43 store double %A1.0, double* %arrayidx3, align 8 44 ret i32 undef 45 } 46 47 48 ;int foo(double * restrict B, double * restrict A, int n, int m) { 49 ; double R=A[1]; 50 ; double G=A[0]; 51 ; for (int i=0; i < 100; i++) { 52 ; R += 10; 53 ; G += 10; 54 ; R *= 4; 55 ; G *= 4; 56 ; R += 4; 57 ; G += 4; 58 ; } 59 ; B[0] = G; 60 ; B[1] = R; 61 ; return 0; 62 ;} 63 64 ;CHECK: foo2 65 ;CHECK: load <2 x double> 66 ;CHECK: phi <2 x double> 67 ;CHECK: fmul <2 x double> 68 ;CHECK: store <2 x double> 69 ;CHECK: ret 70 define i32 @foo2(double* noalias nocapture %B, double* noalias nocapture %A, i32 %n, i32 %m) #0 { 71 entry: 72 %arrayidx = getelementptr inbounds double* %A, i64 1 73 %0 = load double* %arrayidx, align 8 74 %1 = load double* %A, align 8 75 br label %for.body 76 77 for.body: ; preds = %for.body, %entry 78 %i.019 = phi i32 [ 0, %entry ], [ %inc, %for.body ] 79 %G.018 = phi double [ %1, %entry ], [ %add5, %for.body ] 80 %R.017 = phi double [ %0, %entry ], [ %add4, %for.body ] 81 %add = fadd double %R.017, 1.000000e+01 82 %add2 = fadd double %G.018, 1.000000e+01 83 %mul = fmul double %add, 4.000000e+00 84 %mul3 = fmul double %add2, 4.000000e+00 85 %add4 = fadd double %mul, 4.000000e+00 86 %add5 = fadd double %mul3, 4.000000e+00 87 %inc = add nsw i32 %i.019, 1 88 %exitcond = icmp eq i32 %inc, 100 89 br i1 %exitcond, label %for.end, label %for.body 90 91 for.end: ; preds = %for.body 92 store double %add5, double* %B, align 8 93 %arrayidx7 = getelementptr inbounds double* %B, i64 1 94 store double %add4, double* %arrayidx7, align 8 95 ret i32 0 96 } 97 98