1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 define void @test1(i32* %P) {
4 store i32 undef, i32* %P
5 store i32 123, i32* undef
6 store i32 124, i32* null
9 ; CHECK-NEXT: store i32 123, i32* undef
10 ; CHECK-NEXT: store i32 undef, i32* null
11 ; CHECK-NEXT: ret void
14 define void @test2(i32* %P) {
15 %X = load i32* %P ; <i32> [#uses=1]
16 %Y = add i32 %X, 0 ; <i32> [#uses=1]
20 ; CHECK-NEXT: ret void
23 ;; Simple sinking tests
26 define i32 @test3(i1 %C) {
28 br i1 %C, label %Cond, label %Cond2
31 store i32 -987654321, i32* %A
44 ; CHECK-NEXT: %storemerge = phi i32 [ 47, %Cond2 ], [ -987654321, %Cond ]
45 ; CHECK-NEXT: ret i32 %storemerge
49 define i32 @test4(i1 %C) {
52 br i1 %C, label %Cond, label %Cont
55 store i32 -987654321, i32* %A
64 ; CHECK-NEXT: %storemerge = phi i32 [ -987654321, %Cond ], [ 47, %0 ]
65 ; CHECK-NEXT: ret i32 %storemerge
69 define void @test5(i1 %C, i32* %P) {
70 store i32 47, i32* %P, align 1
71 br i1 %C, label %Cond, label %Cont
74 store i32 -987654321, i32* %P, align 1
81 ; CHECK-NEXT: %storemerge = phi i32
82 ; CHECK-NEXT: store i32 %storemerge, i32* %P, align 1
83 ; CHECK-NEXT: ret void