-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[RISCV][FPEnv] Lowering of fpenv intrinsics #141498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
178b8bb
f3cc23e
31f476c
64ad9c7
719234f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+f -verify-machineinstrs | FileCheck %s | ||
; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+f -verify-machineinstrs | FileCheck %s | ||
; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+zfinx -verify-machineinstrs | FileCheck %s | ||
; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+zfinx -verify-machineinstrs | FileCheck %s | ||
; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+f -verify-machineinstrs -O0 | FileCheck %s | ||
; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+f -verify-machineinstrs -O0 | FileCheck %s | ||
|
||
define iXLen @func_get_fpenv() { | ||
; CHECK-LABEL: func_get_fpenv: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: frcsr a0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%fpenv = call iXLen @llvm.get.fpenv.iXLen() | ||
ret iXLen %fpenv | ||
} | ||
|
||
define void @func_set_fpenv(iXLen %fpenv) { | ||
; CHECK-LABEL: func_set_fpenv: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: fscsr a0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to decide how concerned we should be that this generates There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The choice here is determined by compatibility with GLIBC, which uses this form: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gcc always uses To fix -O0 to always use X0 destination, we need a pseudo instruction that doesn't have a destination that we will expand to to use X0 during RISCVAsmPrinter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for explanation. The new inplementation uses custom lowering, which is also necessary to maintain correct implicit reg dependencies. |
||
; CHECK-NEXT: ret | ||
entry: | ||
call void @llvm.set.fpenv.iXLen(iXLen %fpenv) | ||
ret void | ||
} | ||
|
||
define void @func_reset_fpenv() { | ||
; CHECK-LABEL: func_reset_fpenv: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: fscsr zero | ||
; CHECK-NEXT: ret | ||
entry: | ||
call void @llvm.reset.fpenv() | ||
ret void | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need hasSideEffects like the ReadFFLAGS and WriteFFLAGS above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like too rigid restriction. ReadFFLAGS and WriteFFLAGS already have FRM and FFLAGS as inplicit use/def, shouldn't that be sufficient to provide the necessary ordering?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch suffered from the same problem as described in #135172. It has been fixed similar to #135176. The added test checks proper dependencies.