[llvm] r305683 - [ARM] GlobalISel: Support G_ICMP for s8 and s16
Diana Picus via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 19 04:47:29 PDT 2017
Author: rovka
Date: Mon Jun 19 06:47:28 2017
New Revision: 305683
URL: http://llvm.org/viewvc/llvm-project?rev=305683&view=rev
Log:
[ARM] GlobalISel: Support G_ICMP for s8 and s16
Widen to s32 (like all other binary ops).
Modified:
llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.cpp
llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-isel.ll
llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-legalizer.mir
Modified: llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.cpp?rev=305683&r1=305682&r2=305683&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.cpp Mon Jun 19 06:47:28 2017
@@ -87,6 +87,8 @@ ARMLegalizerInfo::ARMLegalizerInfo(const
setAction({G_CONSTANT, s32}, Legal);
setAction({G_ICMP, s1}, Legal);
+ for (auto Ty : {s8, s16})
+ setAction({G_ICMP, 1, Ty}, WidenScalar);
for (auto Ty : {s32, p0})
setAction({G_ICMP, 1, Ty}, Legal);
Modified: llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-isel.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-isel.ll?rev=305683&r1=305682&r2=305683&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-isel.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-isel.ll Mon Jun 19 06:47:28 2017
@@ -385,3 +385,18 @@ entry:
%r = zext i1 %v to i32
ret i32 %r
}
+
+define arm_aapcscc i32 @test_cmp_i16_slt(i16 %a, i16 %b) {
+; CHECK-LABEL: test_cmp_i16_slt:
+; CHECK-DAG: sxth r0, r0
+; CHECK-DAG: sxth r1, r1
+; CHECK-DAG: mov [[V:r[0-9]+]], #0
+; CHECK: cmp r0, r1
+; CHECK: movlt [[V]], #1
+; CHECK: and r0, [[V]], #1
+; CHECK: bx lr
+entry:
+ %v = icmp slt i16 %a, %b
+ %r = zext i1 %v to i32
+ ret i32 %r
+}
Modified: llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-legalizer.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-legalizer.mir?rev=305683&r1=305682&r2=305683&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-legalizer.mir (original)
+++ llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-legalizer.mir Mon Jun 19 06:47:28 2017
@@ -35,7 +35,9 @@
define void @test_constants() { ret void }
- define void @test_icmp_eq_s32() { ret void }
+ define void @test_icmp_s8() { ret void }
+ define void @test_icmp_s16() { ret void }
+ define void @test_icmp_s32() { ret void }
define void @test_fadd_s32() #0 { ret void }
define void @test_fadd_s64() #0 { ret void }
@@ -693,8 +695,62 @@ body: |
BX_RET 14, _, implicit %r0
...
---
-name: test_icmp_eq_s32
-# CHECK-LABEL: name: test_icmp_eq_s32
+name: test_icmp_s8
+# CHECK-LABEL: name: test_icmp_s8
+legalized: false
+# CHECK: legalized: true
+regBankSelected: false
+selected: false
+tracksRegLiveness: true
+registers:
+ - { id: 0, class: _ }
+ - { id: 1, class: _ }
+ - { id: 2, class: _ }
+ - { id: 3, class: _ }
+body: |
+ bb.0:
+ liveins: %r0, %r1
+
+ %0(s8) = COPY %r0
+ %1(s8) = COPY %r1
+ %2(s1) = G_ICMP intpred(ne), %0(s8), %1
+ ; G_ICMP with s8 should widen
+ ; CHECK: {{%[0-9]+}}(s1) = G_ICMP intpred(ne), {{%[0-9]+}}(s32), {{%[0-9]+}}
+ ; CHECK-NOT: {{%[0-9]+}}(s1) = G_ICMP intpred(ne), {{%[0-9]+}}(s8), {{%[0-9]+}}
+ %3(s32) = G_ZEXT %2(s1)
+ %r0 = COPY %3(s32)
+ BX_RET 14, _, implicit %r0
+...
+---
+name: test_icmp_s16
+# CHECK-LABEL: name: test_icmp_s16
+legalized: false
+# CHECK: legalized: true
+regBankSelected: false
+selected: false
+tracksRegLiveness: true
+registers:
+ - { id: 0, class: _ }
+ - { id: 1, class: _ }
+ - { id: 2, class: _ }
+ - { id: 3, class: _ }
+body: |
+ bb.0:
+ liveins: %r0, %r1
+
+ %0(s16) = COPY %r0
+ %1(s16) = COPY %r1
+ %2(s1) = G_ICMP intpred(slt), %0(s16), %1
+ ; G_ICMP with s16 should widen
+ ; CHECK: {{%[0-9]+}}(s1) = G_ICMP intpred(slt), {{%[0-9]+}}(s32), {{%[0-9]+}}
+ ; CHECK-NOT: {{%[0-9]+}}(s1) = G_ICMP intpred(slt), {{%[0-9]+}}(s16), {{%[0-9]+}}
+ %3(s32) = G_ZEXT %2(s1)
+ %r0 = COPY %3(s32)
+ BX_RET 14, _, implicit %r0
+...
+---
+name: test_icmp_s32
+# CHECK-LABEL: name: test_icmp_s32
legalized: false
# CHECK: legalized: true
regBankSelected: false
More information about the llvm-commits
mailing list