[PATCH] D94701: [AArch64][GlobalISel] Assign FPR banks to loads which are used by integer->float conversions.
Amara Emerson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 14 16:33:50 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG036bc798f2ae: [AArch64][GlobalISel] Assign FPR banks to loads which are used by integer… (authored by aemerson).
Changed prior to commit:
https://reviews.llvm.org/D94701?vs=316716&id=316811#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94701/new/
https://reviews.llvm.org/D94701
Files:
llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
llvm/test/CodeGen/AArch64/GlobalISel/regbank-fp-use-def.mir
Index: llvm/test/CodeGen/AArch64/GlobalISel/regbank-fp-use-def.mir
===================================================================
--- llvm/test/CodeGen/AArch64/GlobalISel/regbank-fp-use-def.mir
+++ llvm/test/CodeGen/AArch64/GlobalISel/regbank-fp-use-def.mir
@@ -4,7 +4,7 @@
# Check that we correctly assign register banks based off of instructions which
# only use or only define FPRs.
#
-# For example, G_SITOFP takes in a GPR, but only ever produces values on FPRs.
+# For example, G_SITOFP may take in a GPR, but only ever produces values on FPRs.
# Some instructions can have inputs/outputs on either FPRs or GPRs. If one of
# those instructions takes in the result of a G_SITOFP as a source, we should
# put that source on a FPR.
@@ -361,3 +361,47 @@
%phi:_(s32) = G_PHI %gpr_copy(s32), %bb.0, %unmerge_1(s32), %bb.1
$s0 = COPY %phi(s32)
RET_ReallyLR implicit $s0
+
+...
+---
+name: load_used_by_sitofp
+legalized: true
+tracksRegLiveness: true
+body: |
+ bb.0:
+ liveins: $x0
+ ; The load should be assigned an fpr bank because it's used by the sitofp.
+ ; The sitofp should assign both src and dest to FPR, resulting in no copies.
+ ; CHECK-LABEL: name: load_used_by_sitofp
+ ; CHECK: liveins: $x0
+ ; CHECK: [[COPY:%[0-9]+]]:gpr(p0) = COPY $x0
+ ; CHECK: [[LOAD:%[0-9]+]]:fpr(s32) = G_LOAD [[COPY]](p0) :: (load 4)
+ ; CHECK: [[SITOFP:%[0-9]+]]:fpr(s32) = G_SITOFP [[LOAD]](s32)
+ ; CHECK: $s0 = COPY [[SITOFP]](s32)
+ ; CHECK: RET_ReallyLR implicit $s0
+ %0:_(p0) = COPY $x0
+ %1:_(s32) = G_LOAD %0 :: (load 4)
+ %2:_(s32) = G_SITOFP %1:_(s32)
+ $s0 = COPY %2(s32)
+ RET_ReallyLR implicit $s0
+...
+---
+name: load_used_by_uitofp
+legalized: true
+tracksRegLiveness: true
+body: |
+ bb.0:
+ liveins: $x0
+ ; CHECK-LABEL: name: load_used_by_uitofp
+ ; CHECK: liveins: $x0
+ ; CHECK: [[COPY:%[0-9]+]]:gpr(p0) = COPY $x0
+ ; CHECK: [[LOAD:%[0-9]+]]:fpr(s32) = G_LOAD [[COPY]](p0) :: (load 4)
+ ; CHECK: [[UITOFP:%[0-9]+]]:fpr(s32) = G_UITOFP [[LOAD]](s32)
+ ; CHECK: $s0 = COPY [[UITOFP]](s32)
+ ; CHECK: RET_ReallyLR implicit $s0
+ %0:_(p0) = COPY $x0
+ %1:_(s32) = G_LOAD %0 :: (load 4)
+ %2:_(s32) = G_UITOFP %1:_(s32)
+ $s0 = COPY %2(s32)
+ RET_ReallyLR implicit $s0
+...
Index: llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
===================================================================
--- llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
+++ llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
@@ -680,11 +680,18 @@
break;
}
case TargetOpcode::G_SITOFP:
- case TargetOpcode::G_UITOFP:
+ case TargetOpcode::G_UITOFP: {
if (MRI.getType(MI.getOperand(0).getReg()).isVector())
break;
- OpRegBankIdx = {PMI_FirstFPR, PMI_FirstGPR};
+ // Integer to FP conversions don't necessarily happen between GPR -> FPR
+ // regbanks. They can also be done within an FPR register.
+ Register SrcReg = MI.getOperand(1).getReg();
+ if (getRegBank(SrcReg, MRI, TRI) == &AArch64::FPRRegBank)
+ OpRegBankIdx = {PMI_FirstFPR, PMI_FirstFPR};
+ else
+ OpRegBankIdx = {PMI_FirstFPR, PMI_FirstGPR};
break;
+ }
case TargetOpcode::G_FPTOSI:
case TargetOpcode::G_FPTOUI:
if (MRI.getType(MI.getOperand(0).getReg()).isVector())
@@ -722,7 +729,8 @@
// assume this was a floating point load in the IR.
// If it was not, we would have had a bitcast before
// reaching that instruction.
- if (onlyUsesFP(UseMI, MRI, TRI)) {
+ // Int->FP conversion operations are also captured in onlyDefinesFP().
+ if (onlyUsesFP(UseMI, MRI, TRI) || onlyDefinesFP(UseMI, MRI, TRI)) {
OpRegBankIdx[0] = PMI_FirstFPR;
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94701.316811.patch
Type: text/x-patch
Size: 3812 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210115/d4b9cf83/attachment.bin>
More information about the llvm-commits
mailing list