Tom Stellard | 827ec9b | 2013-11-18 19:43:38 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -march=r600 -mattr=disable-ifcvt -mcpu=redwood | FileCheck %s |
| 2 | |
| 3 | ; This tests for abug where the AMDILCFGStructurizer was crashing on loops |
| 4 | ; like this: |
| 5 | ; |
| 6 | ; for (i = 0; i < x; i++) { |
| 7 | ; if (cond0) { |
| 8 | ; if (cond1) { |
| 9 | ; |
| 10 | ; } else { |
| 11 | ; |
| 12 | ; } |
| 13 | ; if (cond2) { |
| 14 | ; |
| 15 | ; } |
| 16 | ; } |
| 17 | ; } |
| 18 | |
Tom Stellard | 79243d9 | 2014-10-01 17:15:17 +0000 | [diff] [blame] | 19 | ; CHECK-LABEL: {{^}}if_inside_loop: |
Tom Stellard | 827ec9b | 2013-11-18 19:43:38 +0000 | [diff] [blame] | 20 | ; CHECK: LOOP_START_DX10 |
| 21 | ; CHECK: END_LOOP |
| 22 | define void @if_inside_loop(i32 addrspace(1)* %out, i32 %a, i32 %b, i32 %c, i32 %d) { |
| 23 | entry: |
| 24 | br label %for.body |
| 25 | |
| 26 | for.body: |
| 27 | %0 = phi i32 [0, %entry], [%inc, %for.inc] |
| 28 | %val = phi i32 [0, %entry], [%val.for.inc, %for.inc] |
| 29 | %inc = add i32 %0, 1 |
| 30 | %1 = icmp ult i32 10, %a |
| 31 | br i1 %1, label %for.inc, label %if.then |
| 32 | |
| 33 | if.then: |
| 34 | %2 = icmp ne i32 0, %b |
| 35 | br i1 %2, label %if.then.true, label %if.then.false |
| 36 | |
| 37 | if.then.true: |
| 38 | %3 = add i32 %a, %val |
| 39 | br label %if |
| 40 | |
| 41 | if.then.false: |
| 42 | %4 = mul i32 %a, %val |
| 43 | br label %if |
| 44 | |
| 45 | if: |
| 46 | %val.if = phi i32 [%3, %if.then.true], [%4, %if.then.false] |
| 47 | %5 = icmp ne i32 0, %c |
| 48 | br i1 %5, label %if.true, label %for.inc |
| 49 | |
| 50 | if.true: |
| 51 | %6 = add i32 %a, %val.if |
| 52 | br label %for.inc |
| 53 | |
| 54 | for.inc: |
| 55 | %val.for.inc = phi i32 [%val, %for.body], [%val.if, %if], [%6, %if.true] |
| 56 | %7 = icmp ne i32 0, %d |
| 57 | br i1 %7, label %for.body, label %exit |
| 58 | |
| 59 | exit: |
| 60 | store i32 %val.for.inc, i32 addrspace(1)* %out |
| 61 | ret void |
| 62 | } |