Skip to content

Commit 5c613f2

Browse files
authored
[ARM] Add mayRaiseFPException to appropriate instructions and mark all instructions that read/write fpscr rounding bits as doing so (#160698)
Added new register FPSCR_RM to correctly model interactions with rounding mode control bits of fpscr and to avoid performance regressions in normal non-strictfp case This PR is part of the work on adding strict FP support in ARM, which was previously discussed in #137101.
1 parent 57f6923 commit 5c613f2

27 files changed

+546
-462
lines changed

llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ getReservedRegs(const MachineFunction &MF) const {
232232
markSuperRegs(Reserved, ARM::SP);
233233
markSuperRegs(Reserved, ARM::PC);
234234
markSuperRegs(Reserved, ARM::FPSCR);
235+
markSuperRegs(Reserved, ARM::FPSCR_RM);
235236
markSuperRegs(Reserved, ARM::APSR_NZCV);
236237
if (TFI->isFPReserved(MF))
237238
markSuperRegs(Reserved, STI.getFramePointerReg());

llvm/lib/Target/ARM/ARMInstrVFP.td

Lines changed: 81 additions & 31 deletions
Large diffs are not rendered by default.

llvm/lib/Target/ARM/ARMRegisterInfo.td

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@ def Q15 : ARMReg<15, "q15", [D30, D31]>;
177177
}
178178

179179
// Current Program Status Register.
180-
// We model fpscr with two registers: FPSCR models the control bits and will be
181-
// reserved. FPSCR_NZCV models the flag bits and will be unreserved. APSR_NZCV
180+
// We model fpscr with three registers. FPSCR models the control bits and will be
181+
// reserved. FPSCR_RM models rounding mode control bits and will be reserved.
182+
// FPSCR_NZCV models the flag bits and will be unreserved. APSR_NZCV
182183
// models the APSR when it's accessed by some special instructions. In such cases
183184
// it has the same encoding as PC.
184185
def CPSR : ARMReg<0, "cpsr">;
@@ -189,6 +190,9 @@ def FPSCR : ARMReg<3, "fpscr">;
189190
def FPSCR_NZCV : ARMReg<3, "fpscr_nzcv"> {
190191
let Aliases = [FPSCR];
191192
}
193+
def FPSCR_RM : ARMReg<3, "fpscr_rm"> {
194+
let Aliases = [FPSCR];
195+
}
192196
def ITSTATE : ARMReg<4, "itstate">;
193197

194198
// Special Registers - only available in privileged mode.

llvm/test/CodeGen/ARM/GlobalISel/arm-instruction-select-combos.mir

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ body: |
447447
; CHECK-LABEL: name: test_vnmuls
448448
; CHECK: [[COPY:%[0-9]+]]:spr = COPY $s0
449449
; CHECK: [[COPY1:%[0-9]+]]:spr = COPY $s1
450-
; CHECK: [[VNMULS:%[0-9]+]]:spr = VNMULS [[COPY]], [[COPY1]], 14 /* CC::al */, $noreg
450+
; CHECK: [[VNMULS:%[0-9]+]]:spr = nofpexcept VNMULS [[COPY]], [[COPY1]], 14 /* CC::al */, $noreg, implicit $fpscr
451451
; CHECK: $s0 = COPY [[VNMULS]]
452452
; CHECK: BX_RET 14 /* CC::al */, $noreg, implicit $s0
453453
%0(s32) = COPY $s0
@@ -477,7 +477,7 @@ body: |
477477
; CHECK-LABEL: name: test_vnmuls_reassociate
478478
; CHECK: [[COPY:%[0-9]+]]:spr = COPY $s0
479479
; CHECK: [[COPY1:%[0-9]+]]:spr = COPY $s1
480-
; CHECK: [[VNMULS:%[0-9]+]]:spr = VNMULS [[COPY]], [[COPY1]], 14 /* CC::al */, $noreg
480+
; CHECK: [[VNMULS:%[0-9]+]]:spr = nofpexcept VNMULS [[COPY]], [[COPY1]], 14 /* CC::al */, $noreg, implicit $fpscr
481481
; CHECK: $s0 = COPY [[VNMULS]]
482482
; CHECK: BX_RET 14 /* CC::al */, $noreg, implicit $s0
483483
%0(s32) = COPY $s0
@@ -507,7 +507,7 @@ body: |
507507
; CHECK-LABEL: name: test_vnmuld
508508
; CHECK: [[COPY:%[0-9]+]]:dpr = COPY $d0
509509
; CHECK: [[COPY1:%[0-9]+]]:dpr = COPY $d1
510-
; CHECK: [[VNMULD:%[0-9]+]]:dpr = VNMULD [[COPY]], [[COPY1]], 14 /* CC::al */, $noreg
510+
; CHECK: [[VNMULD:%[0-9]+]]:dpr = nofpexcept VNMULD [[COPY]], [[COPY1]], 14 /* CC::al */, $noreg, implicit $fpscr
511511
; CHECK: $d0 = COPY [[VNMULD]]
512512
; CHECK: BX_RET 14 /* CC::al */, $noreg, implicit $d0
513513
%0(s64) = COPY $d0
@@ -539,7 +539,7 @@ body: |
539539
; CHECK: [[COPY:%[0-9]+]]:spr = COPY $s0
540540
; CHECK: [[COPY1:%[0-9]+]]:spr = COPY $s1
541541
; CHECK: [[COPY2:%[0-9]+]]:spr = COPY $s2
542-
; CHECK: [[VFNMAS:%[0-9]+]]:spr = VFNMAS [[COPY2]], [[COPY]], [[COPY1]], 14 /* CC::al */, $noreg
542+
; CHECK: [[VFNMAS:%[0-9]+]]:spr = nofpexcept VFNMAS [[COPY2]], [[COPY]], [[COPY1]], 14 /* CC::al */, $noreg, implicit $fpscr
543543
; CHECK: $s0 = COPY [[VFNMAS]]
544544
; CHECK: BX_RET 14 /* CC::al */, $noreg, implicit $s0
545545
%0(s32) = COPY $s0
@@ -573,7 +573,7 @@ body: |
573573
; CHECK: [[COPY:%[0-9]+]]:dpr = COPY $d0
574574
; CHECK: [[COPY1:%[0-9]+]]:dpr = COPY $d1
575575
; CHECK: [[COPY2:%[0-9]+]]:dpr = COPY $d2
576-
; CHECK: [[VFNMAD:%[0-9]+]]:dpr = VFNMAD [[COPY2]], [[COPY]], [[COPY1]], 14 /* CC::al */, $noreg
576+
; CHECK: [[VFNMAD:%[0-9]+]]:dpr = nofpexcept VFNMAD [[COPY2]], [[COPY]], [[COPY1]], 14 /* CC::al */, $noreg, implicit $fpscr
577577
; CHECK: $d0 = COPY [[VFNMAD]]
578578
; CHECK: BX_RET 14 /* CC::al */, $noreg, implicit $d0
579579
%0(s64) = COPY $d0
@@ -607,7 +607,7 @@ body: |
607607
; CHECK: [[COPY:%[0-9]+]]:spr = COPY $s0
608608
; CHECK: [[COPY1:%[0-9]+]]:spr = COPY $s1
609609
; CHECK: [[COPY2:%[0-9]+]]:spr = COPY $s2
610-
; CHECK: [[VFMSS:%[0-9]+]]:spr = VFMSS [[COPY2]], [[COPY]], [[COPY1]], 14 /* CC::al */, $noreg
610+
; CHECK: [[VFMSS:%[0-9]+]]:spr = nofpexcept VFMSS [[COPY2]], [[COPY]], [[COPY1]], 14 /* CC::al */, $noreg, implicit $fpscr
611611
; CHECK: $s0 = COPY [[VFMSS]]
612612
; CHECK: BX_RET 14 /* CC::al */, $noreg, implicit $s0
613613
%0(s32) = COPY $s0
@@ -640,7 +640,7 @@ body: |
640640
; CHECK: [[COPY:%[0-9]+]]:dpr = COPY $d0
641641
; CHECK: [[COPY1:%[0-9]+]]:dpr = COPY $d1
642642
; CHECK: [[COPY2:%[0-9]+]]:dpr = COPY $d2
643-
; CHECK: [[VFMSD:%[0-9]+]]:dpr = VFMSD [[COPY2]], [[COPY1]], [[COPY]], 14 /* CC::al */, $noreg
643+
; CHECK: [[VFMSD:%[0-9]+]]:dpr = nofpexcept VFMSD [[COPY2]], [[COPY1]], [[COPY]], 14 /* CC::al */, $noreg, implicit $fpscr
644644
; CHECK: $d0 = COPY [[VFMSD]]
645645
; CHECK: BX_RET 14 /* CC::al */, $noreg, implicit $d0
646646
%0(s64) = COPY $d0
@@ -673,7 +673,7 @@ body: |
673673
; CHECK: [[COPY:%[0-9]+]]:spr = COPY $s0
674674
; CHECK: [[COPY1:%[0-9]+]]:spr = COPY $s1
675675
; CHECK: [[COPY2:%[0-9]+]]:spr = COPY $s2
676-
; CHECK: [[VFNMSS:%[0-9]+]]:spr = VFNMSS [[COPY2]], [[COPY]], [[COPY1]], 14 /* CC::al */, $noreg
676+
; CHECK: [[VFNMSS:%[0-9]+]]:spr = nofpexcept VFNMSS [[COPY2]], [[COPY]], [[COPY1]], 14 /* CC::al */, $noreg, implicit $fpscr
677677
; CHECK: $s0 = COPY [[VFNMSS]]
678678
; CHECK: BX_RET 14 /* CC::al */, $noreg, implicit $s0
679679
%0(s32) = COPY $s0

llvm/test/CodeGen/ARM/GlobalISel/arm-select-copy_to_regclass-of-fptosi.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ body: |
1919
bb.1:
2020
; CHECK-LABEL: name: test_fptosi
2121
; CHECK: [[COPY:%[0-9]+]]:spr = COPY $s0
22-
; CHECK: [[VTOSIZS:%[0-9]+]]:spr = VTOSIZS [[COPY]], 14 /* CC::al */, $noreg
22+
; CHECK: [[VTOSIZS:%[0-9]+]]:spr = nofpexcept VTOSIZS [[COPY]], 14 /* CC::al */, $noreg
2323
; CHECK: [[COPY1:%[0-9]+]]:gpr = COPY [[VTOSIZS]]
2424
; CHECK: $r0 = COPY [[COPY1]]
2525
; CHECK: MOVPCLR 14 /* CC::al */, $noreg, implicit $r0

0 commit comments

Comments
 (0)