blob: 1d38efc74576a1d4cf6387d3083d841f850894fc [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001; Mem2reg should not insert dead PHI nodes! The naive algorithm inserts a PHI
2; node in L3, even though there is no load of %A in anything dominated by L3.
3
Dan Gohman3c7d3082009-09-11 18:01:28 +00004; RUN: opt < %s -mem2reg -S | not grep phi
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005
Tanya Lattner97928372008-03-19 07:28:33 +00006define void @test(i32 %B, i1 %C) {
7 %A = alloca i32 ; <i32*> [#uses=4]
8 store i32 %B, i32* %A
9 br i1 %C, label %L1, label %L2
10L1: ; preds = %0
11 store i32 %B, i32* %A
12 %D = load i32* %A ; <i32> [#uses=1]
13 call void @test( i32 %D, i1 false )
Dan Gohmanf17a25c2007-07-18 16:29:46 +000014 br label %L3
Tanya Lattner97928372008-03-19 07:28:33 +000015L2: ; preds = %0
16 %E = load i32* %A ; <i32> [#uses=1]
17 call void @test( i32 %E, i1 true )
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018 br label %L3
Tanya Lattner97928372008-03-19 07:28:33 +000019L3: ; preds = %L2, %L1
Dan Gohmanf17a25c2007-07-18 16:29:46 +000020 ret void
21}
Tanya Lattner97928372008-03-19 07:28:33 +000022