Did you try `hasSideEffects = 1`?
I’m not familiar with AArch64. On X86, we have separate FPCR and FPSR. The former is used for control (rounding, exception mask) and the latter is for status. We modeled all FP instructions that may raise exception by `mayRaiseFPException = 1` and using FPCR. Note, the read of FPCR instruction is another use instead of def FPCR. So it’s not necessary to keep the order of read instruction ahead as source order. Only the write FPCR does. I guess it is the same reason for AArch64? Maybe you can have a check on the write of FPCR.
Thanks
Phoebe
Correct. You do need to add the required support to your backend.
The X86, PowerPC, and SystemZ backends have basically complete support.
The PowerPC backend has a fix to not reschedule floating-point instructions
around function calls if the rounding mode may change. I haven't heard
that the other two have this fix. AArch64 and RISC-V support are both a
work in progress so one of the three fully-supported targets is best to
examine and emulate.
Also be aware that optimization of strict floating-point is a work in
progress, so be prepared for not-so-great performance.
Lastly, there's currently no way to have machine-specific llvm intrinsics
respect "strict" mode. A fix has been proposed, but I don't think anything
has been implemented.
It might have been clang 12 where a warning was introduced that told you
that "strict" floating-point doesn't work for that target and is therefore
disabled. I don't remember exactly which release first had this.
--
Kevin P. Neal
SAS/C and SAS/C++ Compiler
Compute Services
SAS Institute, Inc.
From: llvm-dev <llvm-dev...@lists.llvm.org> On Behalf Of
Cyril Six via llvm-dev
Sent: Wednesday, January 05, 2022 6:44 AM
To: llvm-dev <llvm...@lists.llvm.org>
Subject: [llvm-dev] Implicit Defs and Uses are ignored by pre-RA schedulers
EXTERNAL
Did you try `hasSideEffects = 1`?
I’m not familiar with AArch64. On X86, we have separate FPCR and FPSR. The former is used for control (rounding, exception mask) and the latter is for status. We modeled all FP instructions that may raise exception by `mayRaiseFPException = 1` and using FPCR. Note, the read of FPCR instruction is another use instead of def FPCR. So it’s not necessary to keep the order of read instruction ahead as source order. Only the write FPCR does. I guess it is the same reason for AArch64? Maybe you can have a check on the write of FPCR.
Thanks
Phoebe
On our end, hasSideEffects = 1 and mayRaiseFPException = 1 (combined with implicit Defs and Uses of our $CS register) do not seem to be enough to prevent the reordering of floating-point instructions in pre-RA scheduling.
On 1/6/22 9:32 PM, Kevin Neal wrote:
Correct. You do need to add the required support to your backend.
The X86, PowerPC, and SystemZ backends have basically complete support.
The PowerPC backend has a fix to not reschedule floating-point instructions
around function calls if the rounding mode may change. I haven't heard
that the other two have this fix. AArch64 and RISC-V support are both a
work in progress so one of the three fully-supported targets is best to
examine and emulate.
Also be aware that optimization of strict floating-point is a work in
progress, so be prepared for not-so-great performance.
Lastly, there's currently no way to have machine-specific llvm intrinsics
respect "strict" mode. A fix has been proposed, but I don't think anything
has been implemented.
It might have been clang 12 where a warning was introduced that told you
that "strict" floating-point doesn't work for that target and is therefore
disabled. I don't remember exactly which release first had this.
--
Kevin P. Neal
SAS/C and SAS/C++ CompilerCompute Services
SAS Institute, Inc.
Thank you for the answer - it confirms what I have been seeing.
I will take a closer look to these backends, especially PowerPC's
fix to not reschedule floating-point instructions above function
calls.
Cyril S