[llvm] ae76574 - [RISCV][GISel] Make G_ICMP of pointers legal.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 15 09:25:59 PDT 2023


Author: Craig Topper
Date: 2023-08-15T09:25:52-07:00
New Revision: ae76574d4a9ce2b8d69a41b1b573d168bac617ab

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

LOG: [RISCV][GISel] Make G_ICMP of pointers legal.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D157823

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
    llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir
    llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
index a6f1302daf9e56..a787f08fd2a878 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
@@ -69,7 +69,7 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST) {
       .clampScalar(0, XLenLLT, XLenLLT);
 
   getActionDefinitionsBuilder(G_ICMP)
-      .legalFor({{XLenLLT, XLenLLT}})
+      .legalFor({{XLenLLT, XLenLLT}, {XLenLLT, p0}})
       .widenScalarToNextPow2(1)
       .clampScalar(1, XLenLLT, XLenLLT)
       .clampScalar(0, XLenLLT, XLenLLT);

diff  --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir
index 614dd5b6641dd6..1ff5964fb384e5 100644
--- a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir
@@ -1529,3 +1529,21 @@ body:             |
     PseudoRET implicit $x10
 
 ...
+---
+name:            cmp_eq_ptr
+body:             |
+  bb.0.entry:
+    ; CHECK-LABEL: name: cmp_eq_ptr
+    ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x10
+    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
+    ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[COPY]](p0), [[COPY1]]
+    ; CHECK-NEXT: $x10 = COPY [[ICMP]](s32)
+    ; CHECK-NEXT: PseudoRET implicit $x10
+    %0:_(p0) = COPY $x10
+    %1:_(p0) = COPY $x11
+    %2:_(s1) = G_ICMP intpred(eq), %0(p0), %1
+    %3:_(s32) = G_ANYEXT %2(s1)
+    $x10 = COPY %3(s32)
+    PseudoRET implicit $x10
+
+...

diff  --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir
index 2450e452639efa..9cdd00a3fbf821 100644
--- a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir
@@ -1761,3 +1761,21 @@ body:             |
     PseudoRET implicit $x10
 
 ...
+---
+name:            cmp_ne_ptr
+body:             |
+  bb.0.entry:
+    ; CHECK-LABEL: name: cmp_ne_ptr
+    ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x10
+    ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
+    ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(ne), [[COPY]](p0), [[COPY1]]
+    ; CHECK-NEXT: $x10 = COPY [[ICMP]](s64)
+    ; CHECK-NEXT: PseudoRET implicit $x10
+    %0:_(p0) = COPY $x10
+    %1:_(p0) = COPY $x11
+    %2:_(s1) = G_ICMP intpred(ne), %0(p0), %1
+    %3:_(s64) = G_ANYEXT %2(s1)
+    $x10 = COPY %3(s64)
+    PseudoRET implicit $x10
+
+...


        


More information about the llvm-commits mailing list