[PATCH] D157823: [RISCV][GISel] Make G_ICMP of pointers legal.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 15 09:26:04 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGae76574d4a9c: [RISCV][GISel] Make G_ICMP of pointers legal. (authored by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D157823?vs=549738&id=550362#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157823/new/

https://reviews.llvm.org/D157823

Files:
  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


Index: llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir
===================================================================
--- llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir
+++ llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-icmp.mir
@@ -1761,3 +1761,21 @@
     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
+
+...
Index: llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir
===================================================================
--- llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir
+++ llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-icmp.mir
@@ -1529,3 +1529,21 @@
     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
+
+...
Index: llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
===================================================================
--- llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
+++ llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
@@ -69,7 +69,7 @@
       .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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157823.550362.patch
Type: text/x-patch
Size: 2400 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230815/f8230d86/attachment.bin>


More information about the llvm-commits mailing list