MI.eraseFromParent();
return Legalized;
}
+ case TargetOpcode::G_SITOFP:
+ case TargetOpcode::G_UITOFP: {
+ if (TypeIdx != 1)
+ return UnableToLegalize;
+
+ unsigned Src = MI.getOperand(1).getReg();
+ unsigned SrcExt = MRI.createGenericVirtualRegister(WideTy);
+
+ if (MI.getOpcode() == TargetOpcode::G_SITOFP) {
+ MIRBuilder.buildSExt(SrcExt, Src);
+ } else {
+ assert(MI.getOpcode() == TargetOpcode::G_UITOFP && "Unexpected conv op");
+ MIRBuilder.buildZExt(SrcExt, Src);
+ }
+
+ MIRBuilder.buildInstr(MI.getOpcode())
+ .addDef(MI.getOperand(0).getReg())
+ .addUse(SrcExt);
+
+ MI.eraseFromParent();
+ return Legalized;
+ }
case TargetOpcode::G_LOAD: {
assert(alignTo(MRI.getType(MI.getOperand(0).getReg()).getSizeInBits(), 8) ==
WideTy.getSizeInBits() &&
setAction({G_TRUNC, 1, Ty}, Legal);
// Conversions
- for (auto Ty : { s1, s8, s16, s32, s64 }) {
+ for (auto Ty : { s32, s64 }) {
setAction({G_FPTOSI, 0, Ty}, Legal);
setAction({G_FPTOUI, 0, Ty}, Legal);
setAction({G_SITOFP, 1, Ty}, Legal);
setAction({G_UITOFP, 1, Ty}, Legal);
}
+ for (auto Ty : { s1, s8, s16 }) {
+ setAction({G_FPTOSI, 0, Ty}, Legal);
+ setAction({G_FPTOUI, 0, Ty}, Legal);
+ setAction({G_SITOFP, 1, Ty}, WidenScalar);
+ setAction({G_UITOFP, 1, Ty}, WidenScalar);
+ }
for (auto Ty : { s32, s64 }) {
setAction({G_FPTOSI, 1, Ty}, Legal);
%1:_(s1) = G_TRUNC %0
; CHECK-LABEL: name: test_sitofp_s32_s1
- ; CHECK: %2(s32) = G_SITOFP %1
+ ; CHECK: %3(s32) = G_SEXT %1
+ ; CHECK: %2(s32) = G_SITOFP %3
%2:_(s32) = G_SITOFP %1
...
%1:_(s1) = G_TRUNC %0
; CHECK-LABEL: name: test_uitofp_s32_s1
- ; CHECK: %2(s32) = G_UITOFP %1
+ ; CHECK: %3(s32) = G_ZEXT %1
+ ; CHECK: %2(s32) = G_UITOFP %3
%2:_(s32) = G_UITOFP %1
...
%1:_(s8) = G_TRUNC %0
; CHECK-LABEL: name: test_sitofp_s64_s8
- ; CHECK: %2(s64) = G_SITOFP %1
+ ; CHECK: %3(s32) = G_SEXT %1
+ ; CHECK: %2(s64) = G_SITOFP %3
%2:_(s64) = G_SITOFP %1
...
%1:_(s8) = G_TRUNC %0
; CHECK-LABEL: name: test_uitofp_s64_s8
- ; CHECK: %2(s64) = G_UITOFP %1
+ ; CHECK: %3(s32) = G_ZEXT %1
+ ; CHECK: %2(s64) = G_UITOFP %3
%2:_(s64) = G_UITOFP %1
...
%1:_(s16) = G_TRUNC %0
; CHECK-LABEL: name: test_sitofp_s32_s16
- ; CHECK: %2(s32) = G_SITOFP %1
+ ; CHECK: %3(s32) = G_SEXT %1
+ ; CHECK: %2(s32) = G_SITOFP %3
%2:_(s32) = G_SITOFP %1
...
%1:_(s16) = G_TRUNC %0
; CHECK-LABEL: name: test_uitofp_s32_s16
- ; CHECK: %2(s32) = G_UITOFP %1
+ ; CHECK: %3(s32) = G_ZEXT %1
+ ; CHECK: %2(s32) = G_UITOFP %3
%2:_(s32) = G_UITOFP %1
...