Home | History | Annotate | Download | only in X86
      1 ; RUN: opt < %s -basicaa -slp-vectorizer -dce -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx | 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 target triple = "x86_64-apple-macosx10.9.0"
      5 
      6 ; int foo(int *A) {
      7 ;   int r = A[0], g = A[1], b = A[2], a = A[3];
      8 ;   for (int i=0; i < A[13]; i++) {
      9 ;     r*=18; g*=19; b*=12; a *=9;
     10 ;   }
     11 ;   A[0] = r; A[1] = g; A[2] = b; A[3] = a;
     12 ; }
     13 
     14 ;CHECK-LABEL: @foo
     15 ;CHECK: bitcast i32* %A to <4 x i32>*
     16 ;CHECK-NEXT: load <4 x i32>
     17 ;CHECK: phi <4 x i32>
     18 ;CHECK-NEXT: mul <4 x i32>
     19 ;CHECK-NOT: mul
     20 ;CHECK: phi <4 x i32>
     21 ;CHECK: bitcast i32* %A to <4 x i32>*
     22 ;CHECK-NEXT: store <4 x i32>
     23 ;CHECK-NEXT:ret i32 undef
     24 define i32 @foo(i32* nocapture %A) #0 {
     25 entry:
     26   %0 = load i32* %A, align 4
     27   %arrayidx1 = getelementptr inbounds i32* %A, i64 1
     28   %1 = load i32* %arrayidx1, align 4
     29   %arrayidx2 = getelementptr inbounds i32* %A, i64 2
     30   %2 = load i32* %arrayidx2, align 4
     31   %arrayidx3 = getelementptr inbounds i32* %A, i64 3
     32   %3 = load i32* %arrayidx3, align 4
     33   %arrayidx4 = getelementptr inbounds i32* %A, i64 13
     34   %4 = load i32* %arrayidx4, align 4
     35   %cmp24 = icmp sgt i32 %4, 0
     36   br i1 %cmp24, label %for.body, label %for.end
     37 
     38 for.body:                                         ; preds = %entry, %for.body
     39   %i.029 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
     40   %a.028 = phi i32 [ %mul7, %for.body ], [ %3, %entry ]
     41   %b.027 = phi i32 [ %mul6, %for.body ], [ %2, %entry ]
     42   %g.026 = phi i32 [ %mul5, %for.body ], [ %1, %entry ]
     43   %r.025 = phi i32 [ %mul, %for.body ], [ %0, %entry ]
     44   %mul = mul nsw i32 %r.025, 18
     45   %mul5 = mul nsw i32 %g.026, 19
     46   %mul6 = mul nsw i32 %b.027, 12
     47   %mul7 = mul nsw i32 %a.028, 9
     48   %inc = add nsw i32 %i.029, 1
     49   %cmp = icmp slt i32 %inc, %4
     50   br i1 %cmp, label %for.body, label %for.end
     51 
     52 for.end:                                          ; preds = %for.body, %entry
     53   %a.0.lcssa = phi i32 [ %3, %entry ], [ %mul7, %for.body ]
     54   %b.0.lcssa = phi i32 [ %2, %entry ], [ %mul6, %for.body ]
     55   %g.0.lcssa = phi i32 [ %1, %entry ], [ %mul5, %for.body ]
     56   %r.0.lcssa = phi i32 [ %0, %entry ], [ %mul, %for.body ]
     57   store i32 %r.0.lcssa, i32* %A, align 4
     58   store i32 %g.0.lcssa, i32* %arrayidx1, align 4
     59   store i32 %b.0.lcssa, i32* %arrayidx2, align 4
     60   store i32 %a.0.lcssa, i32* %arrayidx3, align 4
     61   ret i32 undef
     62 }
     63 
     64 
     65