Home | History | Annotate | Download | only in LoopVectorize
      1 ; This test verifies that the loop vectorizer will NOT produce a tail
      2 ; loop with the optimize for size or the minimize size attributes.
      3 ; REQUIRES: asserts
      4 ; RUN: opt < %s -loop-vectorize -S | FileCheck %s
      5 
      6 target datalayout = "E-m:e-p:32:32-i64:32-f64:32:64-a:0:32-n32-S128"
      7 
      8 @tab = common global [32 x i8] zeroinitializer, align 1
      9 
     10 define i32 @foo_optsize() #0 {
     11 ; CHECK-LABEL: @foo_optsize(
     12 ; CHECK-NOT: <2 x i8>
     13 ; CHECK-NOT: <4 x i8>
     14 
     15 entry:
     16   br label %for.body
     17 
     18 for.body:                                         ; preds = %for.body, %entry
     19   %i.08 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
     20   %arrayidx = getelementptr inbounds [32 x i8], [32 x i8]* @tab, i32 0, i32 %i.08
     21   %0 = load i8, i8* %arrayidx, align 1
     22   %cmp1 = icmp eq i8 %0, 0
     23   %. = select i1 %cmp1, i8 2, i8 1
     24   store i8 %., i8* %arrayidx, align 1
     25   %inc = add nsw i32 %i.08, 1
     26   %exitcond = icmp eq i32 %i.08, 202
     27   br i1 %exitcond, label %for.end, label %for.body
     28 
     29 for.end:                                          ; preds = %for.body
     30   ret i32 0
     31 }
     32 
     33 attributes #0 = { optsize }
     34 
     35 define i32 @foo_minsize() #1 {
     36 ; CHECK-LABEL: @foo_minsize(
     37 ; CHECK-NOT: <2 x i8>
     38 ; CHECK-NOT: <4 x i8>
     39 
     40 entry:
     41   br label %for.body
     42 
     43 for.body:                                         ; preds = %for.body, %entry
     44   %i.08 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
     45   %arrayidx = getelementptr inbounds [32 x i8], [32 x i8]* @tab, i32 0, i32 %i.08
     46   %0 = load i8, i8* %arrayidx, align 1
     47   %cmp1 = icmp eq i8 %0, 0
     48   %. = select i1 %cmp1, i8 2, i8 1
     49   store i8 %., i8* %arrayidx, align 1
     50   %inc = add nsw i32 %i.08, 1
     51   %exitcond = icmp eq i32 %i.08, 202
     52   br i1 %exitcond, label %for.end, label %for.body
     53 
     54 for.end:                                          ; preds = %for.body
     55   ret i32 0
     56 }
     57 
     58 attributes #1 = { minsize }
     59 
     60