[AArch64][GlobalISel] Legalize narrow scalar fp->int conversions.
Since we're now avoiding operations using narrow scalar integer types, we have to legalize the integer side of the FP conversions. This requires teaching the legalizer how to do that. llvm-svn: 292828
This commit is contained in:
parent
cfb384d39d
commit
b6137063eb
|
@ -273,6 +273,20 @@ LegalizerHelper::widenScalar(MachineInstr &MI, unsigned TypeIdx, LLT WideTy) {
|
|||
MI.eraseFromParent();
|
||||
return Legalized;
|
||||
}
|
||||
case TargetOpcode::G_FPTOSI:
|
||||
case TargetOpcode::G_FPTOUI: {
|
||||
if (TypeIdx != 0)
|
||||
return UnableToLegalize;
|
||||
|
||||
unsigned DstExt = MRI.createGenericVirtualRegister(WideTy);
|
||||
MIRBuilder.buildInstr(MI.getOpcode())
|
||||
.addDef(DstExt)
|
||||
.addUse(MI.getOperand(1).getReg());
|
||||
|
||||
MIRBuilder.buildTrunc(MI.getOperand(0).getReg(), DstExt);
|
||||
MI.eraseFromParent();
|
||||
return Legalized;
|
||||
}
|
||||
case TargetOpcode::G_SITOFP:
|
||||
case TargetOpcode::G_UITOFP: {
|
||||
if (TypeIdx != 1)
|
||||
|
|
|
@ -151,9 +151,8 @@ AArch64LegalizerInfo::AArch64LegalizerInfo() {
|
|||
setAction({G_UITOFP, 1, Ty}, Legal);
|
||||
}
|
||||
for (auto Ty : { s1, s8, s16 }) {
|
||||
// FIXME: These should be widened on types smaller than s32.
|
||||
setAction({G_FPTOSI, 0, Ty}, Legal);
|
||||
setAction({G_FPTOUI, 0, Ty}, Legal);
|
||||
setAction({G_FPTOSI, 0, Ty}, WidenScalar);
|
||||
setAction({G_FPTOUI, 0, Ty}, WidenScalar);
|
||||
setAction({G_SITOFP, 1, Ty}, WidenScalar);
|
||||
setAction({G_UITOFP, 1, Ty}, WidenScalar);
|
||||
}
|
||||
|
|
|
@ -130,7 +130,8 @@ body: |
|
|||
%0:_(s32) = COPY %w0
|
||||
|
||||
; CHECK-LABEL: name: test_fptosi_s1_s32
|
||||
; CHECK: %1(s1) = G_FPTOSI %0
|
||||
; CHECK: %2(s32) = G_FPTOSI %0
|
||||
; CHECK: %1(s1) = G_TRUNC %2
|
||||
%1:_(s1) = G_FPTOSI %0
|
||||
...
|
||||
|
||||
|
@ -142,7 +143,8 @@ body: |
|
|||
%0:_(s32) = COPY %w0
|
||||
|
||||
; CHECK-LABEL: name: test_fptoui_s1_s32
|
||||
; CHECK: %1(s1) = G_FPTOUI %0
|
||||
; CHECK: %2(s32) = G_FPTOUI %0
|
||||
; CHECK: %1(s1) = G_TRUNC %2
|
||||
%1:_(s1) = G_FPTOUI %0
|
||||
...
|
||||
|
||||
|
@ -154,7 +156,8 @@ body: |
|
|||
%0:_(s64) = COPY %x0
|
||||
|
||||
; CHECK-LABEL: name: test_fptosi_s8_s64
|
||||
; CHECK: %1(s8) = G_FPTOSI %0
|
||||
; CHECK: %2(s32) = G_FPTOSI %0
|
||||
; CHECK: %1(s8) = G_TRUNC %2
|
||||
%1:_(s8) = G_FPTOSI %0
|
||||
...
|
||||
|
||||
|
@ -166,7 +169,8 @@ body: |
|
|||
%0:_(s64) = COPY %x0
|
||||
|
||||
; CHECK-LABEL: name: test_fptoui_s8_s64
|
||||
; CHECK: %1(s8) = G_FPTOUI %0
|
||||
; CHECK: %2(s32) = G_FPTOUI %0
|
||||
; CHECK: %1(s8) = G_TRUNC %2
|
||||
%1:_(s8) = G_FPTOUI %0
|
||||
...
|
||||
|
||||
|
@ -178,7 +182,8 @@ body: |
|
|||
%0:_(s32) = COPY %w0
|
||||
|
||||
; CHECK-LABEL: name: test_fptosi_s16_s32
|
||||
; CHECK: %1(s16) = G_FPTOSI %0
|
||||
; CHECK: %2(s32) = G_FPTOSI %0
|
||||
; CHECK: %1(s16) = G_TRUNC %2
|
||||
%1:_(s16) = G_FPTOSI %0
|
||||
...
|
||||
|
||||
|
@ -190,6 +195,7 @@ body: |
|
|||
%0:_(s32) = COPY %w0
|
||||
|
||||
; CHECK-LABEL: name: test_fptoui_s16_s32
|
||||
; CHECK: %1(s16) = G_FPTOUI %0
|
||||
; CHECK: %2(s32) = G_FPTOUI %0
|
||||
; CHECK: %1(s16) = G_TRUNC %2
|
||||
%1:_(s16) = G_FPTOUI %0
|
||||
...
|
||||
|
|
Loading…
Reference in New Issue