84 lines · plain
1; RUN: llc < %s -mtriple=r600 -mcpu=redwood -r600-ir-structurize=0 | FileCheck %s2; Test case for a crash in the AMDILCFGStructurizer from a CFG like this:3;4; entry5; / \6; diamond_head branch_from7; / \ |8; diamond_false diamond_true9; \ /10; done11;12; When the diamond_true branch had more than 100 instructions.13;14;15 16; CHECK-LABEL: {{^}}branch_into_diamond:17; === entry block:18; CHECK: ALU_PUSH_BEFORE19; === Branch instruction (IF):20; CHECK: JUMP21 ; === branch_from block22 ; CHECK: ALU23 ; === Duplicated diamond_true block (There can be more than one ALU clause):24 ; === XXX: We should be able to optimize this so the basic block is not25 ; === duplicated. See comments in26 ; === AMDGPUCFGStructurizer::improveSimpleJumpintoIf()27 ; CHECK: ALU28; === Branch instruction (ELSE):29; CHECK: ELSE30 ; === diamond_head block:31 ; CHECK: ALU_PUSH_BEFORE32 ; === Branch instruction (IF):33 ; CHECK: JUMP34 ; === diamond_true block (There can be more than one ALU clause):35 ; ALU36 ; === Branch instruction (ELSE):37 ; CHECK: ELSE38 ; === diamond_false block plus implicit ENDIF39 ; CHECK: ALU_POP_AFTER40; === Branch instruction (ENDIF):41; CHECK: POP42; === done block:43; CHECK: ALU44; CHECK: MEM_RAT_CACHELESS45; CHECK: CF_END46 47 48define amdgpu_kernel void @branch_into_diamond(ptr addrspace(1) %out, i32 %a, i32 %b, i32 %c) {49entry:50%0 = icmp ne i32 %a, 051 br i1 %0, label %diamond_head, label %branch_from52 53diamond_head:54 %1 = icmp ne i32 %a, 155 br i1 %1, label %diamond_true, label %diamond_false56 57branch_from:58 %2 = add i32 %a, 159 br label %diamond_true60 61diamond_false:62 %3 = add i32 %a, 263 br label %done64 65diamond_true:66 %4 = phi i32 [%2, %branch_from], [%a, %diamond_head]67 ; This block needs to be > 100 ISA instructions to hit the bug,68 ; so we'll use udiv instructions.69 %div0 = udiv i32 %a, %b70 %div1 = udiv i32 %div0, %471 %div2 = udiv i32 %div1, 1172 %div3 = udiv i32 %div2, %a73 %div4 = udiv i32 %div3, %b74 %div5 = udiv i32 %div4, %c75 %div6 = udiv i32 %div5, %div076 %div7 = udiv i32 %div6, %div177 br label %done78 79done:80 %5 = phi i32 [%3, %diamond_false], [%div7, %diamond_true]81 store i32 %5, ptr addrspace(1) %out82 ret void83}84