• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -jump-threading -jump-threading-threshold=3 -S -verify | FileCheck %s
3
4target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
5target triple = "x86_64-unknown-linux-gnu"
6
7@a = global i32 0, align 4
8
9; Show that freeze is not counted when comparing the cost with the threshold
10define void @foo(i32 %cond1, i32 %cond2) {
11; CHECK-LABEL: @foo(
12; CHECK-NEXT:  entry:
13; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i32 [[COND1:%.*]], 0
14; CHECK-NEXT:    br i1 [[TOBOOL]], label [[BB_COND2_THREAD:%.*]], label [[BB_COND2:%.*]]
15; CHECK:       bb.cond2:
16; CHECK-NEXT:    call void @f1()
17; CHECK-NEXT:    [[COND2_FR:%.*]] = freeze i32 [[COND2:%.*]]
18; CHECK-NEXT:    [[X:%.*]] = add i32 [[COND2_FR]], 1
19; CHECK-NEXT:    [[TOBOOL1:%.*]] = icmp eq i32 [[X]], 0
20; CHECK-NEXT:    br i1 [[TOBOOL1]], label [[BB_F4:%.*]], label [[BB_F2:%.*]]
21; CHECK:       bb.cond2.thread:
22; CHECK-NEXT:    [[COND2_FR2:%.*]] = freeze i32 [[COND2]]
23; CHECK-NEXT:    [[X3:%.*]] = add i32 [[COND2_FR2]], 1
24; CHECK-NEXT:    [[TOBOOL14:%.*]] = icmp eq i32 [[X3]], 0
25; CHECK-NEXT:    br i1 [[TOBOOL14]], label [[BB_F3:%.*]], label [[BB_F2]]
26; CHECK:       bb.f2:
27; CHECK-NEXT:    call void @f2()
28; CHECK-NEXT:    br label [[EXIT:%.*]]
29; CHECK:       bb.f3:
30; CHECK-NEXT:    call void @f3()
31; CHECK-NEXT:    br label [[EXIT]]
32; CHECK:       bb.f4:
33; CHECK-NEXT:    [[PTR5:%.*]] = phi i32* [ null, [[BB_COND2]] ]
34; CHECK-NEXT:    call void @f4()
35; CHECK-NEXT:    br label [[EXIT]]
36; CHECK:       exit:
37; CHECK-NEXT:    ret void
38;
39entry:
40  %tobool = icmp eq i32 %cond1, 0
41  br i1 %tobool, label %bb.cond2, label %bb.f1
42
43bb.f1:
44  call void @f1()
45  br label %bb.cond2
46
47bb.cond2:
48  %ptr = phi i32* [ null, %bb.f1 ], [ @a, %entry ]
49  %cond2.fr = freeze i32 %cond2
50  %x = add i32 %cond2.fr, 1
51  %tobool1 = icmp eq i32 %x, 0
52  br i1 %tobool1, label %bb.file, label %bb.f2
53
54bb.f2:
55  call void @f2()
56  br label %exit
57
58bb.file:
59  %cmp = icmp eq i32* %ptr, null
60  br i1 %cmp, label %bb.f4, label %bb.f3
61
62bb.f3:
63  call void @f3()
64  br label %exit
65
66bb.f4:
67  call void @f4()
68  br label %exit
69
70exit:
71  ret void
72}
73
74declare void @f1()
75
76declare void @f2()
77
78declare void @f3()
79
80declare void @f4()
81