[llvm] 0702d4e - [GlobalIsel][X86] Move G_ICMP legalization before legacy handling and merge 32-bit/64-bit handling

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 4 09:02:18 PDT 2023


Author: Simon Pilgrim
Date: 2023-06-04T17:01:57+01:00
New Revision: 0702d4e04df906cf011950b2aa8ba08bc63d463e

URL: https://github.com/llvm/llvm-project/commit/0702d4e04df906cf011950b2aa8ba08bc63d463e
DIFF: https://github.com/llvm/llvm-project/commit/0702d4e04df906cf011950b2aa8ba08bc63d463e.diff

LOG: [GlobalIsel][X86] Move G_ICMP legalization before legacy handling and merge 32-bit/64-bit handling

I've kept the legalForCartesianProduct call, but this requires us to maintain 32-bit/64-bit integer lists - we might want to just use legalIf and perform the type pair set matching manually.

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86LegalizerInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/X86LegalizerInfo.cpp
index ec84c57851636..626ef556bf172 100644
--- a/llvm/lib/Target/X86/X86LegalizerInfo.cpp
+++ b/llvm/lib/Target/X86/X86LegalizerInfo.cpp
@@ -200,6 +200,14 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
       .clampScalar(0, s8, sMaxScalar)
       .scalarize(0);
 
+  // integer comparison
+  const std::initializer_list<LLT> IntTypes32 = {s8, s16, s32, p0};
+  const std::initializer_list<LLT> IntTypes64 = {s8, s16, s32, s64, p0};
+
+  getActionDefinitionsBuilder(G_ICMP)
+      .legalForCartesianProduct({s8}, Is64Bit ? IntTypes64 : IntTypes32)
+      .clampScalar(0, s8, s8);
+
   // bswap
   getActionDefinitionsBuilder(G_BSWAP)
       .legalIf([=](const LegalityQuery &Query) {
@@ -314,13 +322,6 @@ void X86LegalizerInfo::setLegalizerInfo32bit() {
   LegacyInfo.setAction({G_PTR_ADD, p0}, LegacyLegalizeActions::Legal);
   LegacyInfo.setAction({G_PTR_ADD, 1, s32}, LegacyLegalizeActions::Legal);
 
-  if (!Subtarget.is64Bit()) {
-    // Comparison
-    getActionDefinitionsBuilder(G_ICMP)
-        .legalForCartesianProduct({s8}, {s8, s16, s32, p0})
-        .clampScalar(0, s8, s8);
-  }
-
   // Control-flow
   LegacyInfo.setAction({G_BRCOND, s1}, LegacyLegalizeActions::Legal);
 
@@ -355,9 +356,7 @@ void X86LegalizerInfo::setLegalizerInfo64bit() {
   if (!Subtarget.is64Bit())
     return;
 
-  const LLT p0 = LLT::pointer(0, TM.getPointerSizeInBits(0));
   const LLT s8 = LLT::scalar(8);
-  const LLT s16 = LLT::scalar(16);
   const LLT s32 = LLT::scalar(32);
   const LLT s64 = LLT::scalar(64);
   const LLT s128 = LLT::scalar(128);
@@ -400,11 +399,6 @@ void X86LegalizerInfo::setLegalizerInfo64bit() {
       .clampScalar(0, s32, s64)
       .widenScalarToNextPow2(1);
 
-  // Comparison
-  getActionDefinitionsBuilder(G_ICMP)
-      .legalForCartesianProduct({s8}, {s8, s16, s32, s64, p0})
-      .clampScalar(0, s8, s8);
-
   getActionDefinitionsBuilder(G_FCMP)
       .legalForCartesianProduct({s8}, {s32, s64})
       .clampScalar(0, s8, s8)
@@ -417,7 +411,6 @@ void X86LegalizerInfo::setLegalizerInfo64bit() {
                        LegacyLegalizeActions::Legal);
   LegacyInfo.setAction({G_MERGE_VALUES, 1, s128}, LegacyLegalizeActions::Legal);
   LegacyInfo.setAction({G_UNMERGE_VALUES, s128}, LegacyLegalizeActions::Legal);
-
 }
 
 void X86LegalizerInfo::setLegalizerInfoSSE1() {


        


More information about the llvm-commits mailing list