Skip to content

Commit

Permalink
[HardwareLoops] Add support for strictfp functions. (llvm#84531)
Browse files Browse the repository at this point in the history
This pass was adding new function calls without adding the strictfp
attribute as required by the rules laid out in the langref. With this
change a make check has 4-5 fewer failing tests with the Verifier
changes in D146845.

LangRef:
https://llvm.org/docs/LangRef.html#constrained-floating-point-intrinsics

Test failures found with "https://reviews.llvm.org/D146845".
  • Loading branch information
kpneal authored Mar 11, 2024
1 parent 9b2386e commit 702e2da
Show file tree
Hide file tree
Showing 2 changed files with 436 additions and 0 deletions.
8 changes: 8 additions & 0 deletions llvm/lib/CodeGen/HardwareLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,8 @@ Value *HardwareLoop::InitLoopCount() {

Value* HardwareLoop::InsertIterationSetup(Value *LoopCountInit) {
IRBuilder<> Builder(BeginBB->getTerminator());
if (BeginBB->getParent()->getAttributes().hasFnAttr(Attribute::StrictFP))
Builder.setIsFPConstrained(true);
Type *Ty = LoopCountInit->getType();
bool UsePhi = UsePHICounter || Opts.ForcePhi;
Intrinsic::ID ID = UseLoopGuard
Expand Down Expand Up @@ -535,6 +537,9 @@ Value* HardwareLoop::InsertIterationSetup(Value *LoopCountInit) {

void HardwareLoop::InsertLoopDec() {
IRBuilder<> CondBuilder(ExitBranch);
if (ExitBranch->getParent()->getParent()->getAttributes().hasFnAttr(
Attribute::StrictFP))
CondBuilder.setIsFPConstrained(true);

Function *DecFunc =
Intrinsic::getDeclaration(M, Intrinsic::loop_decrement,
Expand All @@ -557,6 +562,9 @@ void HardwareLoop::InsertLoopDec() {

Instruction* HardwareLoop::InsertLoopRegDec(Value *EltsRem) {
IRBuilder<> CondBuilder(ExitBranch);
if (ExitBranch->getParent()->getParent()->getAttributes().hasFnAttr(
Attribute::StrictFP))
CondBuilder.setIsFPConstrained(true);

Function *DecFunc =
Intrinsic::getDeclaration(M, Intrinsic::loop_decrement_reg,
Expand Down
Loading

0 comments on commit 702e2da

Please sign in to comment.