Skip to content

Commit 702e2da

Browse files
authored
[HardwareLoops] Add support for strictfp functions. (#84531)
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".
1 parent 9b2386e commit 702e2da

File tree

2 files changed

+436
-0
lines changed

2 files changed

+436
-0
lines changed

llvm/lib/CodeGen/HardwareLoops.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ Value *HardwareLoop::InitLoopCount() {
503503

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

536538
void HardwareLoop::InsertLoopDec() {
537539
IRBuilder<> CondBuilder(ExitBranch);
540+
if (ExitBranch->getParent()->getParent()->getAttributes().hasFnAttr(
541+
Attribute::StrictFP))
542+
CondBuilder.setIsFPConstrained(true);
538543

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

558563
Instruction* HardwareLoop::InsertLoopRegDec(Value *EltsRem) {
559564
IRBuilder<> CondBuilder(ExitBranch);
565+
if (ExitBranch->getParent()->getParent()->getAttributes().hasFnAttr(
566+
Attribute::StrictFP))
567+
CondBuilder.setIsFPConstrained(true);
560568

561569
Function *DecFunc =
562570
Intrinsic::getDeclaration(M, Intrinsic::loop_decrement_reg,

0 commit comments

Comments
 (0)