• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -loop-vectorize -force-vector-width=4 -verify-scev-maps -S |FileCheck %s
2
3; SCEV expansion uses existing value when the SCEV has no AddRec expr.
4; CHECK: select
5; CHECK-NOT: select
6
7@a = common global [1000 x i16] zeroinitializer, align 16
8
9define i32 @foo(i32 %x, i32 %y) {
10entry:
11  %cmp = icmp slt i32 %x, %y
12  %cond = select i1 %cmp, i32 %x, i32 %y
13  %cmp1.10 = icmp sgt i32 %cond, 0
14  br i1 %cmp1.10, label %for.body.lr.ph, label %for.end
15
16for.body.lr.ph:                                   ; preds = %entry
17  %tmp = sext i32 %cond to i64
18  br label %for.body
19
20for.body:                                         ; preds = %for.body, %for.body.lr.ph
21  %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]
22  %total.011 = phi i32 [ 0, %for.body.lr.ph ], [ %add, %for.body ]
23  %arrayidx = getelementptr inbounds [1000 x i16], [1000 x i16]* @a, i64 0, i64 %indvars.iv
24  %tmp1 = load i16, i16* %arrayidx, align 2
25  %conv = sext i16 %tmp1 to i32
26  %add = add nsw i32 %conv, %total.011
27  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
28  %cmp1 = icmp slt i64 %indvars.iv.next, %tmp
29  br i1 %cmp1, label %for.body, label %for.end.loopexit
30
31for.end.loopexit:                                 ; preds = %for.body
32  %add.lcssa = phi i32 [ %add, %for.body ]
33  br label %for.end
34
35for.end:                                          ; preds = %for.end.loopexit, %entry
36  %total.0.lcssa = phi i32 [ 0, %entry ], [ %add.lcssa, %for.end.loopexit ]
37  ret i32 %total.0.lcssa
38}
39