Files
clang-p2996/llvm/test/CodeGen/RISCV/fpenv.ll
Nitin John Raj d64d3c5a8f [RISCV] Add pass to remove W suffix from ADDIW and SLLIW to improve compressibility
SLLI and ADD are more compressible than SLLIW and ADDW. SLLI/ADD both have a 5-bit register encoding. SLLIW/ADDW have a 3-bit register encoding. They both require the dest to also be one of the sources.

We aggressively form ADDW/SLLIW as it helps hasAllWBitUsers in RISCVISelDAGToDAG to not require recursion. So we need a pass to remove excessive -w suffixes.

Differential Revision: https://reviews.llvm.org/D139948
2022-12-22 14:19:26 -08:00

126 lines
2.9 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=riscv32 -mattr=+f -verify-machineinstrs < %s | FileCheck -check-prefix=RV32IF %s
; RUN: llc -mtriple=riscv64 -mattr=+f -verify-machineinstrs < %s | FileCheck -check-prefix=RV64IF %s
define i32 @func_01() {
; RV32IF-LABEL: func_01:
; RV32IF: # %bb.0:
; RV32IF-NEXT: frrm a0
; RV32IF-NEXT: slli a0, a0, 2
; RV32IF-NEXT: lui a1, 66
; RV32IF-NEXT: addi a1, a1, 769
; RV32IF-NEXT: srl a0, a1, a0
; RV32IF-NEXT: andi a0, a0, 7
; RV32IF-NEXT: ret
;
; RV64IF-LABEL: func_01:
; RV64IF: # %bb.0:
; RV64IF-NEXT: frrm a0
; RV64IF-NEXT: slli a0, a0, 2
; RV64IF-NEXT: lui a1, 66
; RV64IF-NEXT: addiw a1, a1, 769
; RV64IF-NEXT: srl a0, a1, a0
; RV64IF-NEXT: andi a0, a0, 7
; RV64IF-NEXT: ret
%rm = call i32 @llvm.get.rounding()
ret i32 %rm
}
define void @func_02(i32 %rm) {
; RV32IF-LABEL: func_02:
; RV32IF: # %bb.0:
; RV32IF-NEXT: slli a0, a0, 2
; RV32IF-NEXT: lui a1, 66
; RV32IF-NEXT: addi a1, a1, 769
; RV32IF-NEXT: srl a0, a1, a0
; RV32IF-NEXT: andi a0, a0, 7
; RV32IF-NEXT: fsrm a0
; RV32IF-NEXT: ret
;
; RV64IF-LABEL: func_02:
; RV64IF: # %bb.0:
; RV64IF-NEXT: slli a0, a0, 32
; RV64IF-NEXT: srli a0, a0, 30
; RV64IF-NEXT: lui a1, 66
; RV64IF-NEXT: addiw a1, a1, 769
; RV64IF-NEXT: srl a0, a1, a0
; RV64IF-NEXT: andi a0, a0, 7
; RV64IF-NEXT: fsrm a0
; RV64IF-NEXT: ret
call void @llvm.set.rounding(i32 %rm)
ret void
}
define void @func_03() {
; RV32IF-LABEL: func_03:
; RV32IF: # %bb.0:
; RV32IF-NEXT: fsrmi 1
; RV32IF-NEXT: ret
;
; RV64IF-LABEL: func_03:
; RV64IF: # %bb.0:
; RV64IF-NEXT: fsrmi 1
; RV64IF-NEXT: ret
call void @llvm.set.rounding(i32 0)
ret void
}
define void @func_04() {
; RV32IF-LABEL: func_04:
; RV32IF: # %bb.0:
; RV32IF-NEXT: fsrmi 0
; RV32IF-NEXT: ret
;
; RV64IF-LABEL: func_04:
; RV64IF: # %bb.0:
; RV64IF-NEXT: fsrmi 0
; RV64IF-NEXT: ret
call void @llvm.set.rounding(i32 1)
ret void
}
define void @func_05() {
; RV32IF-LABEL: func_05:
; RV32IF: # %bb.0:
; RV32IF-NEXT: fsrmi 3
; RV32IF-NEXT: ret
;
; RV64IF-LABEL: func_05:
; RV64IF: # %bb.0:
; RV64IF-NEXT: fsrmi 3
; RV64IF-NEXT: ret
call void @llvm.set.rounding(i32 2)
ret void
}
define void @func_06() {
; RV32IF-LABEL: func_06:
; RV32IF: # %bb.0:
; RV32IF-NEXT: fsrmi 2
; RV32IF-NEXT: ret
;
; RV64IF-LABEL: func_06:
; RV64IF: # %bb.0:
; RV64IF-NEXT: fsrmi 2
; RV64IF-NEXT: ret
call void @llvm.set.rounding(i32 3)
ret void
}
define void @func_07() {
; RV32IF-LABEL: func_07:
; RV32IF: # %bb.0:
; RV32IF-NEXT: fsrmi 4
; RV32IF-NEXT: ret
;
; RV64IF-LABEL: func_07:
; RV64IF: # %bb.0:
; RV64IF-NEXT: fsrmi 4
; RV64IF-NEXT: ret
call void @llvm.set.rounding(i32 4)
ret void
}
declare void @llvm.set.rounding(i32)
declare i32 @llvm.get.rounding()