blob: 1b05ffbfac9e0a5e34925e7a54f7ce5f566be71e [file] [log] [blame]
James Molloy7c7255e2016-09-08 12:58:04 +00001; RUN: llc %s -o - -O1 -debug-only=consthoist 2>&1 | FileCheck %s
2; REQUIRES: asserts
3
4target datalayout = "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
5target triple = "thumbv6m-apple-ios8.0.0"
6
7declare void @g(i32)
8
9; CHECK: Collect constant i32 -3 from call void @g(i32 -3) with cost 2
10define void @f(i1 %cond) {
11entry:
12 call void @g(i32 -3)
13 br i1 %cond, label %true, label %ret
14
15true:
16 call void @g(i32 -3)
17 br label %ret
18
19ret:
20 ret void
21}
James Molloy753c18f2016-09-08 12:58:12 +000022
23; CHECK: Function: h
24; CHECK-NOT: Collect constant i32 -193 from
25define void @h(i1 %cond, i32 %p, i32 %q) {
26entry:
27 %a = and i32 %p, 4294967103
28 call void @g(i32 %a)
29 br i1 %cond, label %true, label %ret
30
31true:
32 %b = and i32 %q, 4294967103
33 call void @g(i32 %b)
34 br label %ret
35
36ret:
37 ret void
38}
39
James Molloy1454e902016-09-09 13:35:28 +000040; CHECK: Function: test_icmp_neg
41; CHECK-NOT: Collect constant
42define void @test_icmp_neg(i1 %cond, i32 %arg, i32 %arg2) {
43entry:
44 %a = icmp ne i32 %arg, -5
45 call void @g2(i1 %a)
46 br i1 %cond, label %true, label %ret
47
48true:
49 %b = icmp ne i32 %arg2, -5
50 call void @g2(i1 %b)
51 br label %ret
52
53ret:
54 ret void
55}
56declare void @g2(i1)
57
58; CHECK: Function: test_icmp_neg2
59; CHECK: Hoist constant (i32 -500) to BB entry
60define void @test_icmp_neg2(i1 %cond, i32 %arg, i32 %arg2) {
61entry:
62 %a = icmp ne i32 %arg, -500
63 call void @g2(i1 %a)
64 br i1 %cond, label %true, label %ret
65
66true:
67 %b = icmp ne i32 %arg2, -500
68 call void @g2(i1 %b)
69 br label %ret
70
71ret:
72 ret void
73}
James Molloy57d9dfa2016-09-09 13:35:36 +000074
75; CHECK: Function: test_add_neg
76; CHECK-NOT: Collect constant i32 -5
77define void @test_add_neg(i1 %cond, i32 %arg, i32 %arg2) {
78entry:
79 %a = add i32 %arg, -5
80 call void @g(i32 %a)
81 br i1 %cond, label %true, label %ret
82
83true:
84 %b = add i32 %arg2, -5
85 call void @g(i32 %b)
86 br label %ret
87
88ret:
89 ret void
90}