1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=ipsccp -S %s | FileCheck %s
4 @y = common global [1 x i32] zeroinitializer, align 4
5 @x = common global [1 x i32] zeroinitializer, align 4
7 define i32 @eq_undereferenceable(ptr %p) {
8 ; CHECK-LABEL: @eq_undereferenceable(
10 ; CHECK-NEXT: store i32 1, ptr @y, align 4
11 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[P:%.*]], getelementptr inbounds (i32, ptr @x, i64 1)
12 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
14 ; CHECK-NEXT: store i32 2, ptr getelementptr inbounds (i32, ptr @x, i64 1), align 4
15 ; CHECK-NEXT: br label [[IF_END]]
17 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @y, align 4
18 ; CHECK-NEXT: ret i32 [[TMP0]]
21 store i32 1, ptr @y, align 4
22 %cmp = icmp eq ptr %p, getelementptr inbounds (i32, ptr @x, i64 1)
23 br i1 %cmp, label %if.then, label %if.end
25 if.then: ; preds = %entry
26 store i32 2, ptr %p, align 4
29 if.end: ; preds = %if.then, %entry
30 %0 = load i32, ptr @y, align 4
35 define i32 @eq_dereferenceable(ptr %p) {
36 ; CHECK-LABEL: @eq_dereferenceable(
38 ; CHECK-NEXT: store i32 1, ptr @y, align 4
39 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[P:%.*]], @x
40 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
42 ; CHECK-NEXT: store i32 2, ptr @x, align 4
43 ; CHECK-NEXT: br label [[IF_END]]
45 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @y, align 4
46 ; CHECK-NEXT: ret i32 [[TMP0]]
49 store i32 1, ptr @y, align 4
50 %cmp = icmp eq ptr %p, @x
51 br i1 %cmp, label %if.then, label %if.end
53 if.then: ; preds = %entry
54 store i32 2, ptr %p, align 4
57 if.end: ; preds = %if.then, %entry
58 %0 = load i32, ptr @y, align 4
62 define i1 @eq_undereferenceable_cmp_simp(ptr %p) {
63 ; CHECK-LABEL: @eq_undereferenceable_cmp_simp(
65 ; CHECK-NEXT: [[CMP_0:%.*]] = icmp eq ptr [[P:%.*]], getelementptr inbounds (i32, ptr @x, i64 1)
66 ; CHECK-NEXT: br i1 [[CMP_0]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
68 ; CHECK-NEXT: store i32 2, ptr getelementptr inbounds (i32, ptr @x, i64 1), align 4
69 ; CHECK-NEXT: ret i1 true
71 ; CHECK-NEXT: ret i1 false
74 %cmp.0 = icmp eq ptr %p, getelementptr inbounds (i32, ptr @x, i64 1)
75 br i1 %cmp.0, label %if.then, label %if.end
77 if.then: ; preds = %entry
78 store i32 2, ptr %p, align 4
79 %cmp.1 = icmp eq ptr %p, getelementptr inbounds (i32, ptr @x, i64 1)
82 if.end: ; preds = %if.then, %entry
83 %cmp.2 = icmp eq ptr %p, getelementptr inbounds (i32, ptr @x, i64 1)