Home | History | Annotate | Download | only in X86
      1 ; RUN: opt -basicaa -loop-vectorize -force-vector-interleave=1 -S -mcpu=core-avx2
      2 
      3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
      4 target triple = "x86_64-unknown-linux-gnu"
      5 
      6 @b = common global [256 x i32] zeroinitializer, align 16
      7 @a = common global [256 x i32] zeroinitializer, align 16
      8 
      9 ; unsigned int a[256], b[256];
     10 ; void foo() {
     11 ;  for (i = 0; i < 256; i++) {
     12 ;    if (b[i] > a[i])
     13 ;      a[i] = b[i];
     14 ;  }
     15 ; }
     16 
     17 ; CHECK-LABEL: foo
     18 ; CHECK: load <8 x i32>
     19 ; CHECK: icmp ugt <8 x i32>
     20 ; CHECK: masked.store
     21 
     22 define void @foo() {
     23 entry:
     24   br label %for.body
     25 
     26 for.body:                                         ; preds = %for.inc, %entry
     27   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.inc ]
     28   %arrayidx = getelementptr inbounds [256 x i32], [256 x i32]* @b, i64 0, i64 %indvars.iv
     29   %0 = load i32, i32* %arrayidx, align 4
     30   %arrayidx2 = getelementptr inbounds [256 x i32], [256 x i32]* @a, i64 0, i64 %indvars.iv
     31   %1 = load i32, i32* %arrayidx2, align 4
     32   %cmp3 = icmp ugt i32 %0, %1
     33   br i1 %cmp3, label %if.then, label %for.inc
     34 
     35 if.then:                                          ; preds = %for.body
     36   store i32 %0, i32* %arrayidx2, align 4
     37   br label %for.inc
     38 
     39 for.inc:                                          ; preds = %for.body, %if.then
     40   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
     41   %exitcond = icmp eq i64 %indvars.iv.next, 256
     42   br i1 %exitcond, label %for.end, label %for.body
     43 
     44 for.end:                                          ; preds = %for.inc
     45   ret void
     46 }
     47