| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py |
| ; RUN: llc -mtriple riscv32 -mattr=+experimental-zicfilp < %s | FileCheck %s |
| ; RUN: llc -mtriple riscv64 -mattr=+experimental-zicfilp < %s | FileCheck %s |
| ; RUN: llc -mtriple riscv32 < %s | FileCheck %s --check-prefix=NO-ZICFILP |
| ; RUN: llc -mtriple riscv64 < %s | FileCheck %s --check-prefix=NO-ZICFILP |
| |
| ; Test using t2 to jump table branch. |
| define void @above_threshold(i32 signext %in, ptr %out) nounwind { |
| ; CHECK-LABEL: above_threshold: |
| ; CHECK: # %bb.0: # %entry |
| ; CHECK-NEXT: lpad 0 |
| ; CHECK-NEXT: addi a0, a0, -1 |
| ; CHECK-NEXT: li a2, 5 |
| ; CHECK-NEXT: bltu a2, a0, .LBB0_9 |
| ; CHECK-NEXT: # %bb.1: # %entry |
| ; CHECK-NEXT: slli a0, a0, 2 |
| ; CHECK-NEXT: lui a2, %hi(.LJTI0_0) |
| ; CHECK-NEXT: addi a2, a2, %lo(.LJTI0_0) |
| ; CHECK-NEXT: add a0, a2, a0 |
| ; CHECK-NEXT: lw t2, 0(a0) |
| ; CHECK-NEXT: jr t2 |
| ; CHECK-NEXT: .LBB0_2: # %bb1 |
| ; CHECK-NEXT: li a0, 4 |
| ; CHECK-NEXT: j .LBB0_8 |
| ; CHECK-NEXT: .LBB0_3: # %bb5 |
| ; CHECK-NEXT: li a0, 100 |
| ; CHECK-NEXT: j .LBB0_8 |
| ; CHECK-NEXT: .LBB0_4: # %bb3 |
| ; CHECK-NEXT: li a0, 2 |
| ; CHECK-NEXT: j .LBB0_8 |
| ; CHECK-NEXT: .LBB0_5: # %bb4 |
| ; CHECK-NEXT: li a0, 1 |
| ; CHECK-NEXT: j .LBB0_8 |
| ; CHECK-NEXT: .LBB0_6: # %bb2 |
| ; CHECK-NEXT: li a0, 3 |
| ; CHECK-NEXT: j .LBB0_8 |
| ; CHECK-NEXT: .LBB0_7: # %bb6 |
| ; CHECK-NEXT: li a0, 200 |
| ; CHECK-NEXT: .LBB0_8: # %exit |
| ; CHECK-NEXT: sw a0, 0(a1) |
| ; CHECK-NEXT: .LBB0_9: # %exit |
| ; CHECK-NEXT: ret |
| ; |
| ; NO-ZICFILP-LABEL: above_threshold: |
| ; NO-ZICFILP: # %bb.0: # %entry |
| ; NO-ZICFILP-NEXT: addi a0, a0, -1 |
| ; NO-ZICFILP-NEXT: li a2, 5 |
| ; NO-ZICFILP-NEXT: bltu a2, a0, .LBB0_9 |
| ; NO-ZICFILP-NEXT: # %bb.1: # %entry |
| ; NO-ZICFILP-NEXT: slli a0, a0, 2 |
| ; NO-ZICFILP-NEXT: lui a2, %hi(.LJTI0_0) |
| ; NO-ZICFILP-NEXT: addi a2, a2, %lo(.LJTI0_0) |
| ; NO-ZICFILP-NEXT: add a0, a2, a0 |
| ; NO-ZICFILP-NEXT: lw a0, 0(a0) |
| ; NO-ZICFILP-NEXT: jr a0 |
| ; NO-ZICFILP-NEXT: .LBB0_2: # %bb1 |
| ; NO-ZICFILP-NEXT: li a0, 4 |
| ; NO-ZICFILP-NEXT: j .LBB0_8 |
| ; NO-ZICFILP-NEXT: .LBB0_3: # %bb5 |
| ; NO-ZICFILP-NEXT: li a0, 100 |
| ; NO-ZICFILP-NEXT: j .LBB0_8 |
| ; NO-ZICFILP-NEXT: .LBB0_4: # %bb3 |
| ; NO-ZICFILP-NEXT: li a0, 2 |
| ; NO-ZICFILP-NEXT: j .LBB0_8 |
| ; NO-ZICFILP-NEXT: .LBB0_5: # %bb4 |
| ; NO-ZICFILP-NEXT: li a0, 1 |
| ; NO-ZICFILP-NEXT: j .LBB0_8 |
| ; NO-ZICFILP-NEXT: .LBB0_6: # %bb2 |
| ; NO-ZICFILP-NEXT: li a0, 3 |
| ; NO-ZICFILP-NEXT: j .LBB0_8 |
| ; NO-ZICFILP-NEXT: .LBB0_7: # %bb6 |
| ; NO-ZICFILP-NEXT: li a0, 200 |
| ; NO-ZICFILP-NEXT: .LBB0_8: # %exit |
| ; NO-ZICFILP-NEXT: sw a0, 0(a1) |
| ; NO-ZICFILP-NEXT: .LBB0_9: # %exit |
| ; NO-ZICFILP-NEXT: ret |
| entry: |
| switch i32 %in, label %exit [ |
| i32 1, label %bb1 |
| i32 2, label %bb2 |
| i32 3, label %bb3 |
| i32 4, label %bb4 |
| i32 5, label %bb5 |
| i32 6, label %bb6 |
| ] |
| bb1: |
| store i32 4, ptr %out |
| br label %exit |
| bb2: |
| store i32 3, ptr %out |
| br label %exit |
| bb3: |
| store i32 2, ptr %out |
| br label %exit |
| bb4: |
| store i32 1, ptr %out |
| br label %exit |
| bb5: |
| store i32 100, ptr %out |
| br label %exit |
| bb6: |
| store i32 200, ptr %out |
| br label %exit |
| exit: |
| ret void |
| } |