51 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 52; RUN: llc -mtriple=riscv64 -mattr=+zicond < %s | FileCheck %s --check-prefixes=CHECK,CHEAP3; RUN: llc -mtriple=riscv64 -mattr=+zicond,+predictable-select-expensive < %s | FileCheck %s --check-prefixes=CHECK,EXPENSIVE4 5; Test has not predictable select, which should not be transformed to a branch6define i32 @test1(i32 %a) {7; CHECK-LABEL: test1:8; CHECK: # %bb.0: # %entry9; CHECK-NEXT: sext.w a1, a010; CHECK-NEXT: slti a1, a1, 111; CHECK-NEXT: addiw a0, a0, -112; CHECK-NEXT: czero.nez a0, a0, a113; CHECK-NEXT: ret14entry:15 %cmp = icmp slt i32 %a, 116 %dec = sub i32 %a, 117 %res = select i1 %cmp, i32 0, i32 %dec, !prof !018 ret i32 %res19}20 21; Test has highly predictable select according to profile data,22; which should be transformed to a branch on cores with enabled TunePredictableSelectIsExpensive23define i32 @test2(i32 %a) {24; CHEAP-LABEL: test2:25; CHEAP: # %bb.0: # %entry26; CHEAP-NEXT: sext.w a1, a027; CHEAP-NEXT: slti a1, a1, 128; CHEAP-NEXT: addiw a0, a0, -129; CHEAP-NEXT: czero.nez a0, a0, a130; CHEAP-NEXT: ret31;32; EXPENSIVE-LABEL: test2:33; EXPENSIVE: # %bb.0: # %entry34; EXPENSIVE-NEXT: sext.w a1, a035; EXPENSIVE-NEXT: blez a1, .LBB1_236; EXPENSIVE-NEXT: # %bb.1: # %select.false37; EXPENSIVE-NEXT: addiw a0, a0, -138; EXPENSIVE-NEXT: ret39; EXPENSIVE-NEXT: .LBB1_2:40; EXPENSIVE-NEXT: li a0, 041; EXPENSIVE-NEXT: ret42entry:43 %cmp = icmp slt i32 %a, 144 %dec = sub i32 %a, 145 %res = select i1 %cmp, i32 0, i32 %dec, !prof !146 ret i32 %res47}48 49!0 = !{!"branch_weights", i32 1, i32 1}50!1 = !{!"branch_weights", i32 1, i32 1000}51