1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
6 "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32"
7 target triple = "i386-pc-linux-gnu"
9 define void @test1(i32 %x) nounwind {
10 ; CHECK-LABEL: @test1(
12 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[X:%.*]], 0
13 ; CHECK-NEXT: [[TMP1:%.*]] = xor i1 [[TMP0]], true
14 ; CHECK-NEXT: call void @llvm.assume(i1 [[TMP1]])
15 ; CHECK-NEXT: ret void
18 %0 = icmp eq i32 %x, 0 ; <i1> [#uses=1]
19 br i1 %0, label %bb, label %return
22 %1 = load volatile i32, ptr null
26 return: ; preds = %entry
30 define void @test1_no_null_opt(i32 %x) nounwind #0 {
31 ; CHECK-LABEL: @test1_no_null_opt(
33 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[X:%.*]], 0
34 ; CHECK-NEXT: [[TMP1:%.*]] = xor i1 [[TMP0]], true
35 ; CHECK-NEXT: call void @llvm.assume(i1 [[TMP1]])
36 ; CHECK-NEXT: ret void
39 %0 = icmp eq i32 %x, 0 ; <i1> [#uses=1]
40 br i1 %0, label %bb, label %return
43 %1 = load volatile i32, ptr null
47 return: ; preds = %entry
52 define void @test2() nounwind {
53 ; CHECK-LABEL: @test2(
55 ; CHECK-NEXT: unreachable
63 define void @test2_no_null_opt() nounwind #0 {
64 ; CHECK-LABEL: @test2_no_null_opt(
66 ; CHECK-NEXT: store i32 4, ptr null, align 4
67 ; CHECK-NEXT: ret void
75 define void @test3() nounwind {
76 ; CHECK-LABEL: @test3(
78 ; CHECK-NEXT: store volatile i32 4, ptr null, align 4
79 ; CHECK-NEXT: ret void
82 store volatile i32 4, ptr null
87 define void @test3_no_null_opt() nounwind #0 {
88 ; CHECK-LABEL: @test3_no_null_opt(
90 ; CHECK-NEXT: store volatile i32 4, ptr null, align 4
91 ; CHECK-NEXT: ret void
94 store volatile i32 4, ptr null
99 ; Check store before unreachable.
100 define void @test4(i1 %C, ptr %P) {
101 ; CHECK-LABEL: @test4(
103 ; CHECK-NEXT: br i1 [[C:%.*]], label [[T:%.*]], label [[F:%.*]]
105 ; CHECK-NEXT: store volatile i32 0, ptr [[P:%.*]], align 4
106 ; CHECK-NEXT: unreachable
108 ; CHECK-NEXT: ret void
111 br i1 %C, label %T, label %F
113 store volatile i32 0, ptr %P
119 ; Check cmpxchg before unreachable.
120 define void @test5(i1 %C, ptr %P) {
121 ; CHECK-LABEL: @test5(
123 ; CHECK-NEXT: [[TMP0:%.*]] = xor i1 [[C:%.*]], true
124 ; CHECK-NEXT: call void @llvm.assume(i1 [[TMP0]])
125 ; CHECK-NEXT: ret void
128 br i1 %C, label %T, label %F
130 cmpxchg volatile ptr %P, i32 0, i32 1 seq_cst seq_cst
136 ; Check atomicrmw before unreachable.
137 define void @test6(i1 %C, ptr %P) {
138 ; CHECK-LABEL: @test6(
140 ; CHECK-NEXT: [[TMP0:%.*]] = xor i1 [[C:%.*]], true
141 ; CHECK-NEXT: call void @llvm.assume(i1 [[TMP0]])
142 ; CHECK-NEXT: ret void
145 br i1 %C, label %T, label %F
147 atomicrmw volatile xchg ptr %P, i32 0 seq_cst
153 attributes #0 = { null_pointer_is_valid }