From: Jessica Paquette Date: Tue, 3 Aug 2021 23:42:22 +0000 (-0700) Subject: [AArch64][GlobalISel] Widen G_FPTO*I before clamping X-Git-Tag: upstream/15.0.7~34683 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7d97de60b3ecd52e2a427dff661cdd1ca99617e9;p=platform%2Fupstream%2Fllvm.git [AArch64][GlobalISel] Widen G_FPTO*I before clamping Going through our legalization rules and doing some cleanup. Widening and then clamping is usually easier than clamping and then widening. This allows us to legalize some weird types like s88. Differential Revision: https://reviews.llvm.org/D107413 --- diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp index 2bd3889..279fdcf 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -459,10 +459,10 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST) // Conversions getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI}) .legalForCartesianProduct({s32, s64, v2s64, v4s32, v2s32}) - .clampScalar(0, s32, s64) .widenScalarToNextPow2(0) - .clampScalar(1, s32, s64) - .widenScalarToNextPow2(1); + .clampScalar(0, s32, s64) + .widenScalarToNextPow2(1) + .clampScalar(1, s32, s64); getActionDefinitionsBuilder({G_SITOFP, G_UITOFP}) .legalForCartesianProduct({s32, s64, v2s64, v4s32, v2s32}) diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-fptoi.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-fptoi.mir index b2ee3a6..6b7b617 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-fptoi.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-fptoi.mir @@ -266,3 +266,48 @@ body: | %1:_(s128) = G_FPTOSI %0 $q0 = COPY %1 ... +--- +name: test_fptosi_s88_s88 +body: | + bb.0: + liveins: $x0 + ; CHECK-LABEL: name: test_fptosi_s88_s88 + ; CHECK: [[DEF:%[0-9]+]]:_(s88) = G_IMPLICIT_DEF + ; CHECK: [[FPTOSI:%[0-9]+]]:_(s128) = G_FPTOSI [[DEF]](s88) + ; CHECK: [[TRUNC:%[0-9]+]]:_(s88) = G_TRUNC [[FPTOSI]](s128) + ; CHECK: %trunc:_(s64) = G_TRUNC [[TRUNC]](s88) + ; CHECK: $x0 = COPY %trunc(s64) + %0:_(s88) = G_IMPLICIT_DEF + %1:_(s88) = G_FPTOSI %0 + %trunc:_(s64) = G_TRUNC %1 + $x0 = COPY %trunc +... +--- +name: test_fptosi_s88_s64 +body: | + bb.0: + liveins: $x0 + ; CHECK-LABEL: name: test_fptosi_s88_s64 + ; CHECK: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF + ; CHECK: [[FPTOSI:%[0-9]+]]:_(s128) = G_FPTOSI [[DEF]](s64) + ; CHECK: [[TRUNC:%[0-9]+]]:_(s88) = G_TRUNC [[FPTOSI]](s128) + ; CHECK: %trunc:_(s64) = G_TRUNC [[TRUNC]](s88) + ; CHECK: $x0 = COPY %trunc(s64) + %0:_(s64) = G_IMPLICIT_DEF + %1:_(s88) = G_FPTOSI %0 + %trunc:_(s64) = G_TRUNC %1 + $x0 = COPY %trunc +... +--- +name: test_fptosi_s64_s88 +body: | + bb.0: + liveins: $x0 + ; CHECK-LABEL: name: test_fptosi_s64_s88 + ; CHECK: [[DEF:%[0-9]+]]:_(s88) = G_IMPLICIT_DEF + ; CHECK: [[FPEXT:%[0-9]+]]:_(s128) = G_FPEXT [[DEF]](s88) + ; CHECK: [[FPTOSI:%[0-9]+]]:_(s64) = G_FPTOSI [[FPEXT]](s128) + ; CHECK: $x0 = COPY [[FPTOSI]](s64) + %0:_(s88) = G_IMPLICIT_DEF + %1:_(s64) = G_FPTOSI %0 + $x0 = COPY %1