1 ; RUN: llc -spec-exec-max-speculation-cost=0 -march=r600 -r600-ir-structurize=0 -mcpu=redwood < %s | FileCheck %s
3 ; These tests make sure the compiler is optimizing branches using predicates
4 ; when it is legal to do so.
6 ; CHECK-LABEL: {{^}}simple_if:
7 ; CHECK: PRED_SET{{[EGN][ET]*}}_INT * Pred,
8 ; CHECK: LSHL * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}, 1, Pred_sel
9 define amdgpu_kernel void @simple_if(i32 addrspace(1)* %out, i32 %in) {
11 %cmp0 = icmp sgt i32 %in, 0
12 br i1 %cmp0, label %IF, label %ENDIF
15 %tmp1 = shl i32 %in, 1
19 %tmp2 = phi i32 [ %in, %entry ], [ %tmp1, %IF ]
20 store i32 %tmp2, i32 addrspace(1)* %out
24 ; CHECK-LABEL: {{^}}simple_if_else:
25 ; CHECK: PRED_SET{{[EGN][ET]*}}_INT * Pred,
26 ; CHECK: LSH{{[LR] \* T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}, 1, Pred_sel
27 ; CHECK: LSH{{[LR] \* T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}, 1, Pred_sel
28 define amdgpu_kernel void @simple_if_else(i32 addrspace(1)* %out, i32 %in) {
30 %0 = icmp sgt i32 %in, 0
31 br i1 %0, label %IF, label %ELSE
42 %3 = phi i32 [ %1, %IF ], [ %2, %ELSE ]
43 store i32 %3, i32 addrspace(1)* %out
47 ; CHECK-LABEL: {{^}}nested_if:
48 ; CHECK: ALU_PUSH_BEFORE
51 ; CHECK: PRED_SET{{[EGN][ET]*}}_INT * Exec
52 ; CHECK: PRED_SET{{[EGN][ET]*}}_INT * Pred,
53 ; CHECK: LSHL * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}, 1, Pred_sel
54 define amdgpu_kernel void @nested_if(i32 addrspace(1)* %out, i32 %in) {
56 %0 = icmp sgt i32 %in, 0
57 br i1 %0, label %IF0, label %ENDIF
61 %2 = icmp sgt i32 %1, 0
62 br i1 %2, label %IF1, label %ENDIF
69 %4 = phi i32 [%in, %entry], [%1, %IF0], [%3, %IF1]
70 store i32 %4, i32 addrspace(1)* %out
74 ; CHECK-LABEL: {{^}}nested_if_else:
75 ; CHECK: ALU_PUSH_BEFORE
78 ; CHECK: PRED_SET{{[EGN][ET]*}}_INT * Exec
79 ; CHECK: PRED_SET{{[EGN][ET]*}}_INT * Pred,
80 ; CHECK: LSH{{[LR] \* T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}, 1, Pred_sel
81 ; CHECK: LSH{{[LR] \* T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}, 1, Pred_sel
82 define amdgpu_kernel void @nested_if_else(i32 addrspace(1)* %out, i32 %in) {
84 %0 = icmp sgt i32 %in, 0
85 br i1 %0, label %IF0, label %ENDIF
89 %2 = icmp sgt i32 %1, 0
90 br i1 %2, label %IF1, label %ELSE1
101 %5 = phi i32 [%in, %entry], [%3, %IF1], [%4, %ELSE1]
102 store i32 %5, i32 addrspace(1)* %out