166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; RUN: opt < %s -instcombine -S | FileCheck %s 266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumandefine void @test1(i32* %P) { 466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman store i32 undef, i32* %P 566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman store i32 123, i32* undef 666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman store i32 124, i32* null 766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman ret void 866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK: @test1( 966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK-NEXT: store i32 123, i32* undef 1066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK-NEXT: store i32 undef, i32* null 1166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK-NEXT: ret void 1266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman} 1366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 1466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumandefine void @test2(i32* %P) { 1566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman %X = load i32* %P ; <i32> [#uses=1] 1666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman %Y = add i32 %X, 0 ; <i32> [#uses=1] 1766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman store i32 %Y, i32* %P 1866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman ret void 1966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK: @test2 2066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK-NEXT: ret void 2166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman} 2266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 2366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman;; Simple sinking tests 2466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 2566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; "if then else" 2666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumandefine i32 @test3(i1 %C) { 2766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman %A = alloca i32 2866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman br i1 %C, label %Cond, label %Cond2 2966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 3066b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanCond: 3166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman store i32 -987654321, i32* %A 3266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman br label %Cont 3366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 3466b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanCond2: 3566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman store i32 47, i32* %A 3666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman br label %Cont 3766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 3866b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanCont: 3966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman %V = load i32* %A 4066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman ret i32 %V 4166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK: @test3 4266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK-NOT: alloca 4366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK: Cont: 4466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK-NEXT: %storemerge = phi i32 [ 47, %Cond2 ], [ -987654321, %Cond ] 4566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK-NEXT: ret i32 %storemerge 4666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman} 4766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 4866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; "if then" 4966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumandefine i32 @test4(i1 %C) { 5066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman %A = alloca i32 5166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman store i32 47, i32* %A 5266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman br i1 %C, label %Cond, label %Cont 5366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 5466b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanCond: 5566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman store i32 -987654321, i32* %A 5666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman br label %Cont 5766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 5866b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanCont: 5966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman %V = load i32* %A 6066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman ret i32 %V 6166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK: @test4 6266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK-NOT: alloca 6366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK: Cont: 6466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK-NEXT: %storemerge = phi i32 [ -987654321, %Cond ], [ 47, %0 ] 6566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK-NEXT: ret i32 %storemerge 6666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman} 6766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 6866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; "if then" 6966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumandefine void @test5(i1 %C, i32* %P) { 7066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman store i32 47, i32* %P, align 1 7166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman br i1 %C, label %Cond, label %Cont 7266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 7366b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanCond: 7466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman store i32 -987654321, i32* %P, align 1 7566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman br label %Cont 7666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 7766b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanCont: 7866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman ret void 7966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK: @test5 8066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK: Cont: 8166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK-NEXT: %storemerge = phi i32 8266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK-NEXT: store i32 %storemerge, i32* %P, align 1 8366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman; CHECK-NEXT: ret void 8466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman} 8566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 86