1 ; RUN: opt < %s -simplifycfg -S | FileCheck %s
5 "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32"
6 target triple = "i386-pc-linux-gnu"
8 define void @test1(i32 %x) nounwind {
10 %0 = icmp eq i32 %x, 0 ; <i1> [#uses=1]
11 br i1 %0, label %bb, label %return
14 %1 = load volatile i32, i32* null
18 return: ; preds = %entry
20 ; CHECK-LABEL: @test1(
21 ; CHECK: load volatile
24 define void @test1_no_null_opt(i32 %x) nounwind #0 {
26 %0 = icmp eq i32 %x, 0 ; <i1> [#uses=1]
27 br i1 %0, label %bb, label %return
30 %1 = load volatile i32, i32* null
34 return: ; preds = %entry
36 ; CHECK-LABEL: @test1_no_null_opt(
37 ; CHECK: load volatile
42 define void @test2() nounwind {
47 ; CHECK-LABEL: @test2(
48 ; CHECK: call void @llvm.trap
52 define void @test2_no_null_opt() nounwind #0 {
56 ; CHECK-LABEL: @test2_no_null_opt(
57 ; CHECK: store i32 4, i32* null
58 ; CHECK-NOT: call void @llvm.trap
63 define void @test3() nounwind {
65 store volatile i32 4, i32* null
68 ; CHECK-LABEL: @test3(
69 ; CHECK: store volatile i32 4, i32* null
73 define void @test3_no_null_opt() nounwind #0 {
75 store volatile i32 4, i32* null
78 ; CHECK-LABEL: @test3_no_null_opt(
79 ; CHECK: store volatile i32 4, i32* null
83 ; Check store before unreachable.
84 define void @test4(i1 %C, i32* %P) {
85 ; CHECK-LABEL: @test4(
87 ; CHECK-NEXT: br i1 %C
89 br i1 %C, label %T, label %F
91 store volatile i32 0, i32* %P
97 ; Check cmpxchg before unreachable.
98 define void @test5(i1 %C, i32* %P) {
99 ; CHECK-LABEL: @test5(
101 ; CHECK-NEXT: br i1 %C
103 br i1 %C, label %T, label %F
105 cmpxchg volatile i32* %P, i32 0, i32 1 seq_cst seq_cst
111 ; Check atomicrmw before unreachable.
112 define void @test6(i1 %C, i32* %P) {
113 ; CHECK-LABEL: @test6(
115 ; CHECK-NEXT: br i1 %C
117 br i1 %C, label %T, label %F
119 atomicrmw volatile xchg i32* %P, i32 0 seq_cst
125 attributes #0 = { "null-pointer-is-valid"="true" }