[PATCH] D65079: [GlobalISel][AArch64] Fix narrowScalar for G_ICMP

Petar Avramovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 05:59:09 PDT 2019


Petar.Avramovic created this revision.
Petar.Avramovic added reviewers: brzycki, dsanders.
Herald added subscribers: llvm-commits, kristof.beyls, javed.absar, rovka.
Herald added a project: LLVM.

Repository:
  rL LLVM

https://reviews.llvm.org/D65079

Files:
  lib/Target/AArch64/AArch64LegalizerInfo.cpp
  test/CodeGen/AArch64/GlobalISel/legalize-cmp.mir


Index: test/CodeGen/AArch64/GlobalISel/legalize-cmp.mir
===================================================================
--- test/CodeGen/AArch64/GlobalISel/legalize-cmp.mir
+++ test/CodeGen/AArch64/GlobalISel/legalize-cmp.mir
@@ -38,3 +38,46 @@
     $w0 = COPY %14(s32)
 
 ...
+---
+name:            test_icmp_s128
+alignment:       2
+tracksRegLiveness: true
+body:             |
+  bb.1.entry:
+    liveins: $x0, $x1
+
+    ; CHECK-LABEL: name: test_icmp_s128
+    ; CHECK: liveins: $x0, $x1
+    ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
+    ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
+    ; CHECK: [[LOAD:%[0-9]+]]:_(s64) = G_LOAD [[COPY]](p0) :: (load 8, align 16)
+    ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
+    ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[C]](s64)
+    ; CHECK: [[LOAD1:%[0-9]+]]:_(s64) = G_LOAD [[GEP]](p0) :: (load 8)
+    ; CHECK: [[LOAD2:%[0-9]+]]:_(s64) = G_LOAD [[COPY1]](p0) :: (load 8, align 16)
+    ; CHECK: [[GEP1:%[0-9]+]]:_(p0) = G_GEP [[COPY1]], [[C]](s64)
+    ; CHECK: [[LOAD3:%[0-9]+]]:_(s64) = G_LOAD [[GEP1]](p0) :: (load 8)
+    ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(slt), [[LOAD1]](s64), [[LOAD3]]
+    ; CHECK: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[LOAD1]](s64), [[LOAD3]]
+    ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP1]](s32)
+    ; CHECK: [[ICMP2:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[LOAD]](s64), [[LOAD2]]
+    ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[ICMP2]](s32)
+    ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY [[ICMP]](s32)
+    ; CHECK: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[TRUNC]](s1), [[COPY2]], [[COPY3]]
+    ; CHECK: [[COPY4:%[0-9]+]]:_(s32) = COPY [[SELECT]](s32)
+    ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
+    ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY4]], [[C1]]
+    ; CHECK: [[COPY5:%[0-9]+]]:_(s32) = COPY [[AND]](s32)
+    ; CHECK: $w0 = COPY [[COPY5]](s32)
+    ; CHECK: RET_ReallyLR implicit $w0
+    %0:_(p0) = COPY $x0
+    %1:_(p0) = COPY $x1
+    %2:_(s128) = G_LOAD %0(p0) :: (load 16)
+    %3:_(s128) = G_LOAD %1(p0) :: (load 16)
+    %4:_(s1) = G_ICMP intpred(slt), %2(s128), %3
+    %5:_(s8) = G_ZEXT %4(s1)
+    %6:_(s32) = G_ANYEXT %5(s8)
+    $w0 = COPY %6(s32)
+    RET_ReallyLR implicit $w0
+
+...
Index: lib/Target/AArch64/AArch64LegalizerInfo.cpp
===================================================================
--- lib/Target/AArch64/AArch64LegalizerInfo.cpp
+++ lib/Target/AArch64/AArch64LegalizerInfo.cpp
@@ -307,8 +307,8 @@
                  {v8s16, v8s16},
                  {v8s8, v8s8},
                  {v16s8, v16s8}})
-      .clampScalar(0, s32, s32)
       .clampScalar(1, s32, s64)
+      .clampScalar(0, s32, s32)
       .minScalarEltSameAsIf(
           [=](const LegalityQuery &Query) {
             const LLT &Ty = Query.Types[0];


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65079.211067.patch
Type: text/x-patch
Size: 2813 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190722/908c21f1/attachment.bin>


More information about the llvm-commits mailing list