[PATCH] D47917: [ARM] Lower llvm.ctlz.i32 to a libcall when clz is not available.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 11 15:59:55 PDT 2018
efriedma added a comment.
I'm not checking for optsize because I don't think it makes sense to inline even when optimizing for speed... although maybe that's not right. The current code for Thumb1 is something like the following (which is essentially computing `popcount(nextpoweroftwo(x)-1)`).
test:
.fnstart
@ %bb.0:
lsrs r1, r0, #1
orrs r1, r0
lsrs r0, r1, #2
orrs r0, r1
lsrs r1, r0, #4
orrs r1, r0
lsrs r0, r1, #8
orrs r0, r1
lsrs r1, r0, #16
orrs r1, r0
mvns r0, r1
lsrs r1, r0, #1
ldr r2, .LCPI0_0
ands r2, r1
subs r0, r0, r2
ldr r1, .LCPI0_1
lsrs r2, r0, #2
ands r0, r1
ands r2, r1
adds r0, r0, r2
lsrs r1, r0, #4
adds r0, r0, r1
ldr r1, .LCPI0_2
ands r1, r0
ldr r0, .LCPI0_3
muls r0, r1, r0
lsrs r0, r0, #24
bx lr
.p2align 2
@ %bb.1:
.LCPI0_0:
.long 1431655765 @ 0x55555555
.LCPI0_1:
.long 858993459 @ 0x33333333
.LCPI0_2:
.long 252645135 @ 0xf0f0f0f
.LCPI0_3:
.long 16843009 @ 0x1010101
.Lfunc_end0:
.size test, .Lfunc_end0-test
Repository:
rL LLVM
https://reviews.llvm.org/D47917
More information about the llvm-commits
mailing list