Skip to content

Commit 7fa4c46

Browse files
committed
[RISCV] Allow 'Pr' for f64 on rv32 D in X
I think it's not unreasonable that people writing for just rv32 dinx code would expect to be able to use `Pr` for double values, given that these are actually passed in a pair of GPRs.
1 parent a63ead4 commit 7fa4c46

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20629,6 +20629,8 @@ RISCVTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
2062920629
return std::make_pair(0U, &RISCV::GPRCRegClass);
2063020630
}
2063120631
} else if (Constraint == "Pr") {
20632+
if (VT == MVT::f64 && !Subtarget.is64Bit() && Subtarget.hasStdExtZdinx())
20633+
return std::make_pair(0U, &RISCV::GPRF64PairCRegClass);
2063220634
return std::make_pair(0U, &RISCV::GPRPairNoX0RegClass);
2063320635
}
2063420636

llvm/test/CodeGen/RISCV/zdinx-asm-constraint.ll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,32 @@ entry:
2626
ret void
2727
}
2828

29+
define dso_local void @zdinx_asm_Pr(ptr nocapture noundef writeonly %a, double noundef %b, double noundef %c) nounwind {
30+
; CHECK-LABEL: zdinx_asm_Pr:
31+
; CHECK: # %bb.0: # %entry
32+
; CHECK-NEXT: addi sp, sp, -16
33+
; CHECK-NEXT: sw s0, 12(sp) # 4-byte Folded Spill
34+
; CHECK-NEXT: sw s1, 8(sp) # 4-byte Folded Spill
35+
; CHECK-NEXT: mv a5, a4
36+
; CHECK-NEXT: mv s1, a2
37+
; CHECK-NEXT: mv a4, a3
38+
; CHECK-NEXT: mv s0, a1
39+
; CHECK-NEXT: #APP
40+
; CHECK-NEXT: fsgnjx.d a2, s0, a4
41+
; CHECK-NEXT: #NO_APP
42+
; CHECK-NEXT: sw a2, 8(a0)
43+
; CHECK-NEXT: sw a3, 12(a0)
44+
; CHECK-NEXT: lw s0, 12(sp) # 4-byte Folded Reload
45+
; CHECK-NEXT: lw s1, 8(sp) # 4-byte Folded Reload
46+
; CHECK-NEXT: addi sp, sp, 16
47+
; CHECK-NEXT: ret
48+
entry:
49+
%arrayidx = getelementptr inbounds double, ptr %a, i32 1
50+
%0 = tail call double asm "fsgnjx.d $0, $1, $2", "=^Pr,^Pr,^Pr"(double %b, double %c)
51+
store double %0, ptr %arrayidx, align 8
52+
ret void
53+
}
54+
2955
define dso_local void @zfinx_asm(ptr nocapture noundef writeonly %a, float noundef %b, float noundef %c) nounwind {
3056
; CHECK-LABEL: zfinx_asm:
3157
; CHECK: # %bb.0: # %entry

0 commit comments

Comments
 (0)