1 ; RUN: opt < %s -simplifycfg -S | FileCheck %s 2 ; PR2967 3 4 target datalayout = 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" 7 8 define void @test1(i32 %x) nounwind { 9 entry: 10 %0 = icmp eq i32 %x, 0 ; <i1> [#uses=1] 11 br i1 %0, label %bb, label %return 12 13 bb: ; preds = %entry 14 %1 = load volatile i32* null 15 unreachable 16 17 br label %return 18 return: ; preds = %entry 19 ret void 20 ; CHECK-LABEL: @test1( 21 ; CHECK: load volatile 22 } 23 24 ; rdar://7958343 25 define void @test2() nounwind { 26 entry: 27 store i32 4,i32* null 28 ret void 29 30 ; CHECK-LABEL: @test2( 31 ; CHECK: call void @llvm.trap 32 ; CHECK: unreachable 33 } 34 35 ; PR7369 36 define void @test3() nounwind { 37 entry: 38 store volatile i32 4, i32* null 39 ret void 40 41 ; CHECK-LABEL: @test3( 42 ; CHECK: store volatile i32 4, i32* null 43 ; CHECK: ret 44 } 45 46 ; Check store before unreachable. 47 define void @test4(i1 %C, i32* %P) { 48 ; CHECK-LABEL: @test4( 49 ; CHECK: entry: 50 ; CHECK-NEXT: br i1 %C 51 entry: 52 br i1 %C, label %T, label %F 53 T: 54 store volatile i32 0, i32* %P 55 unreachable 56 F: 57 ret void 58 } 59 60 ; Check cmpxchg before unreachable. 61 define void @test5(i1 %C, i32* %P) { 62 ; CHECK-LABEL: @test5( 63 ; CHECK: entry: 64 ; CHECK-NEXT: br i1 %C 65 entry: 66 br i1 %C, label %T, label %F 67 T: 68 cmpxchg volatile i32* %P, i32 0, i32 1 seq_cst seq_cst 69 unreachable 70 F: 71 ret void 72 } 73 74 ; Check atomicrmw before unreachable. 75 define void @test6(i1 %C, i32* %P) { 76 ; CHECK-LABEL: @test6( 77 ; CHECK: entry: 78 ; CHECK-NEXT: br i1 %C 79 entry: 80 br i1 %C, label %T, label %F 81 T: 82 atomicrmw volatile xchg i32* %P, i32 0 seq_cst 83 unreachable 84 F: 85 ret void 86 } 87 88