2016-06-24 14:30:22 +08:00
|
|
|
; RUN: llc -spec-exec-max-speculation-cost=0 -march=r600 -r600-ir-structurize=0 -mcpu=redwood < %s | FileCheck %s
|
2013-02-06 01:09:13 +08:00
|
|
|
|
|
|
|
; These tests make sure the compiler is optimizing branches using predicates
|
|
|
|
; when it is legal to do so.
|
|
|
|
|
2016-06-15 08:11:01 +08:00
|
|
|
; CHECK-LABEL: {{^}}simple_if:
|
2013-05-03 05:52:30 +08:00
|
|
|
; CHECK: PRED_SET{{[EGN][ET]*}}_INT * Pred,
|
|
|
|
; CHECK: LSHL * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}, 1, Pred_sel
|
2013-02-06 01:09:13 +08:00
|
|
|
define void @simple_if(i32 addrspace(1)* %out, i32 %in) {
|
|
|
|
entry:
|
2016-06-15 08:11:01 +08:00
|
|
|
%cmp0 = icmp sgt i32 %in, 0
|
|
|
|
br i1 %cmp0, label %IF, label %ENDIF
|
2013-02-06 01:09:13 +08:00
|
|
|
|
|
|
|
IF:
|
2016-06-15 08:11:01 +08:00
|
|
|
%tmp1 = shl i32 %in, 1
|
2013-02-06 01:09:13 +08:00
|
|
|
br label %ENDIF
|
|
|
|
|
|
|
|
ENDIF:
|
2016-06-15 08:11:01 +08:00
|
|
|
%tmp2 = phi i32 [ %in, %entry ], [ %tmp1, %IF ]
|
|
|
|
store i32 %tmp2, i32 addrspace(1)* %out
|
2013-02-06 01:09:13 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-06-15 08:11:01 +08:00
|
|
|
; CHECK-LABEL: {{^}}simple_if_else:
|
2013-05-03 05:52:30 +08:00
|
|
|
; CHECK: PRED_SET{{[EGN][ET]*}}_INT * Pred,
|
|
|
|
; CHECK: LSH{{[LR] \* T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}, 1, Pred_sel
|
|
|
|
; CHECK: LSH{{[LR] \* T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}, 1, Pred_sel
|
2013-02-06 01:09:13 +08:00
|
|
|
define void @simple_if_else(i32 addrspace(1)* %out, i32 %in) {
|
|
|
|
entry:
|
|
|
|
%0 = icmp sgt i32 %in, 0
|
|
|
|
br i1 %0, label %IF, label %ELSE
|
|
|
|
|
|
|
|
IF:
|
|
|
|
%1 = shl i32 %in, 1
|
|
|
|
br label %ENDIF
|
|
|
|
|
|
|
|
ELSE:
|
|
|
|
%2 = lshr i32 %in, 1
|
|
|
|
br label %ENDIF
|
|
|
|
|
|
|
|
ENDIF:
|
|
|
|
%3 = phi i32 [ %1, %IF ], [ %2, %ELSE ]
|
|
|
|
store i32 %3, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-06-15 08:11:01 +08:00
|
|
|
; CHECK-LABEL: {{^}}nested_if:
|
2013-04-02 05:48:05 +08:00
|
|
|
; CHECK: ALU_PUSH_BEFORE
|
|
|
|
; CHECK: JUMP
|
2013-04-30 08:14:38 +08:00
|
|
|
; CHECK: POP
|
2013-05-03 05:52:30 +08:00
|
|
|
; CHECK: PRED_SET{{[EGN][ET]*}}_INT * Exec
|
|
|
|
; CHECK: PRED_SET{{[EGN][ET]*}}_INT * Pred,
|
|
|
|
; CHECK: LSHL * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}, 1, Pred_sel
|
2013-02-06 01:09:13 +08:00
|
|
|
define void @nested_if(i32 addrspace(1)* %out, i32 %in) {
|
|
|
|
entry:
|
|
|
|
%0 = icmp sgt i32 %in, 0
|
|
|
|
br i1 %0, label %IF0, label %ENDIF
|
|
|
|
|
|
|
|
IF0:
|
|
|
|
%1 = add i32 %in, 10
|
|
|
|
%2 = icmp sgt i32 %1, 0
|
|
|
|
br i1 %2, label %IF1, label %ENDIF
|
|
|
|
|
|
|
|
IF1:
|
|
|
|
%3 = shl i32 %1, 1
|
|
|
|
br label %ENDIF
|
|
|
|
|
|
|
|
ENDIF:
|
|
|
|
%4 = phi i32 [%in, %entry], [%1, %IF0], [%3, %IF1]
|
|
|
|
store i32 %4, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-06-15 08:11:01 +08:00
|
|
|
; CHECK-LABEL: {{^}}nested_if_else:
|
2013-04-02 05:48:05 +08:00
|
|
|
; CHECK: ALU_PUSH_BEFORE
|
|
|
|
; CHECK: JUMP
|
2013-04-30 08:14:38 +08:00
|
|
|
; CHECK: POP
|
2013-05-03 05:52:30 +08:00
|
|
|
; CHECK: PRED_SET{{[EGN][ET]*}}_INT * Exec
|
|
|
|
; CHECK: PRED_SET{{[EGN][ET]*}}_INT * Pred,
|
|
|
|
; CHECK: LSH{{[LR] \* T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}, 1, Pred_sel
|
|
|
|
; CHECK: LSH{{[LR] \* T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}, 1, Pred_sel
|
2013-02-06 01:09:13 +08:00
|
|
|
define void @nested_if_else(i32 addrspace(1)* %out, i32 %in) {
|
|
|
|
entry:
|
|
|
|
%0 = icmp sgt i32 %in, 0
|
|
|
|
br i1 %0, label %IF0, label %ENDIF
|
|
|
|
|
|
|
|
IF0:
|
|
|
|
%1 = add i32 %in, 10
|
|
|
|
%2 = icmp sgt i32 %1, 0
|
|
|
|
br i1 %2, label %IF1, label %ELSE1
|
|
|
|
|
|
|
|
IF1:
|
|
|
|
%3 = shl i32 %1, 1
|
|
|
|
br label %ENDIF
|
|
|
|
|
|
|
|
ELSE1:
|
|
|
|
%4 = lshr i32 %in, 1
|
|
|
|
br label %ENDIF
|
|
|
|
|
|
|
|
ENDIF:
|
|
|
|
%5 = phi i32 [%in, %entry], [%3, %IF1], [%4, %ELSE1]
|
|
|
|
store i32 %5, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|