[PATCH] D157819: [RISCV][GISel] Make G_SELECT of pointers legal
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 15 09:20:25 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG88903fac1ff7: [RISCV][GISel] Make G_SELECT of pointers legal (authored by craig.topper).
Changed prior to commit:
https://reviews.llvm.org/D157819?vs=549733&id=550360#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157819/new/
https://reviews.llvm.org/D157819
Files:
llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-select.mir
llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-select.mir
Index: llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-select.mir
===================================================================
--- llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-select.mir
+++ llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-select.mir
@@ -224,3 +224,25 @@
PseudoRET implicit $x10, implicit $x11, implicit $x12
...
+---
+name: select_ptr
+body: |
+ bb.0.entry:
+ ; CHECK-LABEL: name: select_ptr
+ ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x10
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
+ ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x12
+ ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY2]], [[C]]
+ ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(p0) = G_SELECT [[AND]](s64), [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[SELECT]](p0)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(p0) = COPY $x10
+ %1:_(p0) = COPY $x11
+ %2:_(s64) = COPY $x12
+ %3:_(s1) = G_TRUNC %2(s64)
+ %4:_(p0) = G_SELECT %3(s1), %0(p0), %1(p0)
+ $x10 = COPY %4(p0)
+ PseudoRET implicit $x10
+
+...
Index: llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-select.mir
===================================================================
--- llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-select.mir
+++ llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-select.mir
@@ -199,3 +199,25 @@
PseudoRET implicit $x10, implicit $x11, implicit $x12
...
+---
+name: select_ptr
+body: |
+ bb.0.entry:
+ ; CHECK-LABEL: name: select_ptr
+ ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x10
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
+ ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $x12
+ ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]]
+ ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(p0) = G_SELECT [[AND]](s32), [[COPY]], [[COPY1]]
+ ; CHECK-NEXT: $x10 = COPY [[SELECT]](p0)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(p0) = COPY $x10
+ %1:_(p0) = COPY $x11
+ %2:_(s32) = COPY $x12
+ %3:_(s1) = G_TRUNC %2(s32)
+ %4:_(p0) = G_SELECT %3(s1), %0(p0), %1(p0)
+ $x10 = COPY %4(p0)
+ 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
@@ -75,7 +75,7 @@
.clampScalar(0, XLenLLT, XLenLLT);
getActionDefinitionsBuilder(G_SELECT)
- .legalFor({{XLenLLT, XLenLLT}})
+ .legalFor({{XLenLLT, XLenLLT}, {p0, XLenLLT}})
.widenScalarToNextPow2(0)
.clampScalar(0, XLenLLT, XLenLLT)
.clampScalar(1, XLenLLT, XLenLLT);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157819.550360.patch
Type: text/x-patch
Size: 2888 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230815/ac11bc80/attachment.bin>
More information about the llvm-commits
mailing list