Mark Lacey | 9b5fcf6 | 2016-05-20 18:39:11 +0000 | [diff] [blame] | 1 | ; RUN: opt -S -mergefunc < %s | FileCheck %s |
| 2 | |
| 3 | ; Ensure that we do not merge functions that are identical with the |
| 4 | ; exception of the order of the incoming blocks to a phi. |
| 5 | |
| 6 | ; CHECK-LABEL: define linkonce_odr hidden i1 @first(i2) |
| 7 | define linkonce_odr hidden i1 @first(i2) { |
| 8 | entry: |
| 9 | ; CHECK: switch i2 |
| 10 | switch i2 %0, label %default [ |
| 11 | i2 0, label %L1 |
| 12 | i2 1, label %L2 |
| 13 | i2 -2, label %L3 |
| 14 | ] |
| 15 | default: |
| 16 | unreachable |
| 17 | L1: |
| 18 | br label %done |
| 19 | L2: |
| 20 | br label %done |
| 21 | L3: |
| 22 | br label %done |
| 23 | done: |
| 24 | %result = phi i1 [ true, %L1 ], [ false, %L2 ], [ false, %L3 ] |
| 25 | ; CHECK: ret i1 |
| 26 | ret i1 %result |
| 27 | } |
| 28 | |
| 29 | ; CHECK-LABEL: define linkonce_odr hidden i1 @second(i2) |
| 30 | define linkonce_odr hidden i1 @second(i2) { |
| 31 | entry: |
| 32 | ; CHECK: switch i2 |
| 33 | switch i2 %0, label %default [ |
| 34 | i2 0, label %L1 |
| 35 | i2 1, label %L2 |
| 36 | i2 -2, label %L3 |
| 37 | ] |
| 38 | default: |
| 39 | unreachable |
| 40 | L1: |
| 41 | br label %done |
| 42 | L2: |
| 43 | br label %done |
| 44 | L3: |
| 45 | br label %done |
| 46 | done: |
| 47 | %result = phi i1 [ true, %L3 ], [ false, %L2 ], [ false, %L1 ] |
| 48 | ; CHECK: ret i1 |
| 49 | ret i1 %result |
| 50 | } |