1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc -mtriple=riscv64 -mattr=+zicond < %s | FileCheck %s --check-prefixes=CHECK,CHEAP
3 ; RUN: llc -mtriple=riscv64 -mattr=+zicond,+predictable-select-expensive < %s | FileCheck %s --check-prefixes=CHECK,EXPENSIVE
5 ; Test has not predictable select, which should not be transformed to a branch
6 define i32 @test1(i32 %a) {
8 ; CHECK: # %bb.0: # %entry
9 ; CHECK-NEXT: sext.w a1, a0
10 ; CHECK-NEXT: slti a1, a1, 1
11 ; CHECK-NEXT: addiw a0, a0, -1
12 ; CHECK-NEXT: czero.nez a0, a0, a1
15 %cmp = icmp slt i32 %a, 1
17 %res = select i1 %cmp, i32 0, i32 %dec, !prof !0
21 ; Test has highly predictable select according to profile data,
22 ; which should be transformed to a branch on cores with enabled FeaturePredictableSelectIsExpensive
23 define i32 @test2(i32 %a) {
25 ; CHEAP: # %bb.0: # %entry
26 ; CHEAP-NEXT: sext.w a1, a0
27 ; CHEAP-NEXT: slti a1, a1, 1
28 ; CHEAP-NEXT: addiw a0, a0, -1
29 ; CHEAP-NEXT: czero.nez a0, a0, a1
32 ; EXPENSIVE-LABEL: test2:
33 ; EXPENSIVE: # %bb.0: # %entry
34 ; EXPENSIVE-NEXT: sext.w a1, a0
35 ; EXPENSIVE-NEXT: blez a1, .LBB1_2
36 ; EXPENSIVE-NEXT: # %bb.1: # %select.false
37 ; EXPENSIVE-NEXT: addiw a0, a0, -1
39 ; EXPENSIVE-NEXT: .LBB1_2:
40 ; EXPENSIVE-NEXT: li a0, 0
43 %cmp = icmp slt i32 %a, 1
45 %res = select i1 %cmp, i32 0, i32 %dec, !prof !1
49 !0 = !{!"branch_weights", i32 1, i32 1}
50 !1 = !{!"branch_weights", i32 1, i32 1000}