Dan Gohman | 1880092 | 2009-09-11 18:01:28 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -instcombine -S | grep load | count 3 |
Chris Lattner | f3ecd2d | 2008-06-20 05:12:56 +0000 | [diff] [blame] | 2 | ; PR2471 |
| 3 | |
| 4 | declare i32 @x(i32*) |
| 5 | define i32 @b(i32* %a, i32* %b) { |
| 6 | entry: |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 7 | %tmp1 = load i32, i32* %a |
| 8 | %tmp3 = load i32, i32* %b |
Chris Lattner | f3ecd2d | 2008-06-20 05:12:56 +0000 | [diff] [blame] | 9 | %add = add i32 %tmp1, %tmp3 |
| 10 | %call = call i32 @x( i32* %a ) |
| 11 | %tobool = icmp ne i32 %add, 0 |
| 12 | ; not safe to turn into an uncond load |
| 13 | %cond = select i1 %tobool, i32* %b, i32* %a |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 14 | %tmp8 = load i32, i32* %cond |
Chris Lattner | f3ecd2d | 2008-06-20 05:12:56 +0000 | [diff] [blame] | 15 | ret i32 %tmp8 |
| 16 | } |