175 lines · plain
1# RUN: llc -O0 -mtriple arm-linux-gnueabi -mattr=+v5t -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,CLZ2# RUN: llc -O0 -mtriple thumb-linux-gnueabi -mattr=+v6t2 -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,CLZ3# RUN: llc -O0 -mtriple arm-linux-gnueabi -mattr=-v5t -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,LIBCALLS4--- |5 define void @test_ctlz_s32() { ret void }6 define void @test_ctlz_zero_undef_s32() { ret void }7 8 ; same as above but with extensions9 define void @test_ctlz_s16() { ret void }10 define void @test_ctlz_zero_undef_s8() { ret void }11...12---13name: test_ctlz_s3214# CHECK-LABEL: name: test_ctlz_s3215legalized: false16# CHECK: legalized: true17regBankSelected: false18selected: false19tracksRegLiveness: true20registers:21 - { id: 0, class: _ }22 - { id: 1, class: _ }23body: |24 bb.0:25 liveins: $r026 27 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY $r028 %0(s32) = COPY $r029 30 ; CLZ: [[R:%[0-9]+]]:_(s32) = G_CTLZ [[X]]31 ; LIBCALLS-NOT: G_CTLZ32 ; LIBCALLS: ADJCALLSTACKDOWN33 ; LIBCALLS: $r0 = COPY [[X]]34 ; LIBCALLS: BL &__clzsi2, {{.*}}, implicit $r0, implicit-def $r035 ; LIBCALLS: [[COUNT:%[0-9]+]]:_(s32) = COPY $r036 ; LIBCALLS: ADJCALLSTACKUP37 ; LIBCALLS-NOT: G_CTLZ38 ; LIBCALLS: [[ZERO:%[0-9]+]]:_(s32) = G_CONSTANT i32 039 ; LIBCALLS: [[CMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[X]](s32), [[ZERO]]40 ; LIBCALLS: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 3241 ; LIBCALLS: [[R:%[0-9]+]]:_(s32) = G_SELECT [[CMP]](s1), [[BITS]], [[COUNT]]42 ; LIBCALLS-NOT: G_CTLZ43 %1(s32) = G_CTLZ %044 45 ; CHECK: $r0 = COPY [[R]]46 $r0 = COPY %1(s32)47 BX_RET 14, $noreg, implicit $r048...49---50name: test_ctlz_zero_undef_s3251# CHECK-LABEL: name: test_ctlz_zero_undef_s3252legalized: false53# CHECK: legalized: true54regBankSelected: false55selected: false56tracksRegLiveness: true57registers:58 - { id: 0, class: _ }59 - { id: 1, class: _ }60body: |61 bb.0:62 liveins: $r063 64 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY $r065 %0(s32) = COPY $r066 67 ; CLZ: [[R:%[0-9]+]]:_(s32) = G_CTLZ [[X]]68 ; LIBCALLS-NOT: G_CTLZ69 ; LIBCALLS: ADJCALLSTACKDOWN70 ; LIBCALLS: $r0 = COPY [[X]]71 ; LIBCALLS: BL &__clzsi2, {{.*}}, implicit $r0, implicit-def $r072 ; LIBCALLS: [[R:%[0-9]+]]:_(s32) = COPY $r073 ; LIBCALLS: ADJCALLSTACKUP74 ; LIBCALLS-NOT: G_CTLZ75 %1(s32) = G_CTLZ_ZERO_UNDEF %076 77 ; CHECK: $r0 = COPY [[R]]78 $r0 = COPY %1(s32)79 BX_RET 14, $noreg, implicit $r080...81---82name: test_ctlz_s1683# CHECK-LABEL: name: test_ctlz_s1684legalized: false85# CHECK: legalized: true86regBankSelected: false87selected: false88tracksRegLiveness: true89registers:90 - { id: 0, class: _ }91 - { id: 1, class: _ }92 - { id: 2, class: _ }93 - { id: 3, class: _ }94body: |95 bb.0:96 liveins: $r097 98 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY $r099 ; CHECK: [[BITMASK:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535100 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_AND [[X]], [[BITMASK]]101 %0(s32) = COPY $r0102 %1(s16) = G_TRUNC %0(s32)103 104 ; Check that the operation is performed for 32 bits105 ; CLZ: [[COUNT:%[0-9]+]]:_(s32) = G_CTLZ [[X32]]106 ; LIBCALLS-NOT: G_CTLZ107 ; LIBCALLS: ADJCALLSTACKDOWN108 ; LIBCALLS: $r0 = COPY [[X32]]109 ; LIBCALLS: BL &__clzsi2, {{.*}}, implicit $r0, implicit-def $r0110 ; LIBCALLS: [[UNDEFCOUNT:%[0-9]+]]:_(s32) = COPY $r0111 ; LIBCALLS: ADJCALLSTACKUP112 ; LIBCALLS-NOT: G_CTLZ113 ; LIBCALLS: [[ZERO:%[0-9]+]]:_(s32) = G_CONSTANT i32 0114 ; LIBCALLS: [[CMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), {{%[0-9]+}}(s32), [[ZERO]]115 ; LIBCALLS: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 32116 ; LIBCALLS: [[COUNT:%[0-9]+]]:_(s32) = G_SELECT [[CMP]](s1), [[BITS]], [[UNDEFCOUNT]]117 ; LIBCALLS-NOT: G_CTLZ118 ; CHECK: [[BITDIFF:%[0-9]+]]:_(s32) = G_CONSTANT i32 16119 ; CHECK: [[R32:%[0-9]+]]:_(s32) = G_SUB [[COUNT]], [[BITDIFF]]120 %2(s16) = G_CTLZ %1121 122 ; LIBCALLS: [[SHIFTEDR:%[0-9]+]]:_(s32) = G_SHL [[R32]], [[BITDIFF]]123 ; LIBCALLS: [[R:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDR]], [[BITDIFF]]124 ; LIBCALLS: $r0 = COPY [[R]]125 ; CLZ: $r0 = COPY [[R32]]126 %3(s32) = G_SEXT %2(s16)127 $r0 = COPY %3(s32)128 BX_RET 14, $noreg, implicit $r0129...130---131name: test_ctlz_zero_undef_s8132# CHECK-LABEL: name: test_ctlz_zero_undef_s8133legalized: false134# CHECK: legalized: true135regBankSelected: false136selected: false137tracksRegLiveness: true138registers:139 - { id: 0, class: _ }140 - { id: 1, class: _ }141 - { id: 2, class: _ }142 - { id: 3, class: _ }143body: |144 bb.0:145 liveins: $r0146 147 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY $r0148 ; CHECK: [[BITMASK:%[0-9]+]]:_(s32) = G_CONSTANT i32 255149 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_AND [[X]], [[BITMASK]]150 %0(s32) = COPY $r0151 %1(s8) = G_TRUNC %0(s32)152 153 ; Check that the operation is performed for 32 bits154 ; CHECK: [[BITDIFF:%[0-9]+]]:_(s32) = G_CONSTANT i32 24155 ; CHECK: [[R32:%[0-9]+]]:_(s32) = G_SHL [[X32]], [[BITDIFF]]156 ; LIBCALLS-NOT: G_CTLZ157 ; LIBCALLS: ADJCALLSTACKDOWN158 ; LIBCALLS: $r0 = COPY [[R32]]159 ; LIBCALLS: BL &__clzsi2, {{.*}}, implicit $r0, implicit-def $r0160 ; LIBCALLS: [[COUNT:%[0-9]+]]:_(s32) = COPY $r0161 ; LIBCALLS: ADJCALLSTACKUP162 ; LIBCALLS-NOT: G_CTLZ163 ; CLZ: [[COUNT:%[0-9]+]]:_(s32) = G_CTLZ [[R32]]164 ; CLZ-NOT: G_CTLZ_ZERO_UNDEF165 %2(s8) = G_CTLZ_ZERO_UNDEF %1166 167 ; LIBCALLS: [[SHIFTEDR:%[0-9]+]]:_(s32) = G_SHL [[COUNT]], [[BITDIFF]]168 ; LIBCALLS: [[R:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDR]], [[BITDIFF]]169 ; CLZ: $r0 = COPY [[COUNT]]170 ; LIBCALLS: $r0 = COPY [[R]]171 %3(s32) = G_SEXT %2(s8)172 $r0 = COPY %3(s32)173 BX_RET 14, $noreg, implicit $r0174...175