• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -indvars -S < %s | FileCheck %s
2
3define void @test0(i32* %x) {
4entry:
5  br label %for.inc
6
7for.inc:                                          ; preds = %for.inc, %entry
8  %i.01 = phi i32 [ 0, %entry ], [ %add, %for.inc ]
9  %and = and i32 %i.01, 3
10  %cmp1 = icmp eq i32 %and, 0
11  %cond = select i1 %cmp1, i32 0, i32 1
12  store i32 %cond, i32* %x, align 4
13  %add = add i32 %i.01, 4
14  %cmp = icmp ult i32 %add, 8
15  br i1 %cmp, label %for.inc, label %for.end
16
17for.end:                                          ; preds = %for.inc
18  ret void
19}
20
21; Should fold the condition of the select into constant
22; CHECK-LABEL: void @test0(
23; CHECK:         icmp eq i32 0, 0
24
25define void @test1(i32* %a) {
26entry:
27  br label %for.body
28
29for.body:                                         ; preds = %entry, %for.body
30  %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
31  %mul = mul nsw i32 %i.01, 64
32  %rem = srem i32 %mul, 8
33  %idxprom = sext i32 %rem to i64
34  %arrayidx = getelementptr inbounds i32, i32* %a, i64 %idxprom
35  store i32 %i.01, i32* %arrayidx, align 4
36  %inc = add nsw i32 %i.01, 1
37  %cmp = icmp slt i32 %inc, 64
38  br i1 %cmp, label %for.body, label %for.end
39
40for.end:                                          ; preds = %for.body
41  ret void
42}
43
44; Should fold the rem since %mul is multiple of 8
45; CHECK-LABEL: @test1(
46; CHECK-NOT:     rem
47; CHECK:         sext i32 0 to i64
48