[PATCH] D128911: Emit table lookup from TargetLowering::expandCTTZ()
Shubham Narlawar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 22 04:37:02 PDT 2022
gsocshubham added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:7870
+ SDValue CPIdx = DAG.getConstantPool(CA, getPointerTy(TD),
+ TD.getPrefTypeAlign(Elts[0]->getType()));
+ Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
----------------
barannikov88 wrote:
> You should use the alignment requirement of the array (i.e. CA), not of its element. They may differ.
>From the assembly dump of SPARC/cttz.ll, I am not sure whether to use array element alignment or array alignment?
If I use array alignment `CA`, I get below assembly as compared to `SPARC/cttz.ll` assembly if array element alignment is used. What do you think? Should I update from `CPIdx` to `CA`?
```
f: ! @f
.cfi_startproc
! %bb.0: ! %entry
mov %o0, %o1
cmp %o0, 0
be .LBB0_2
mov %g0, %o0
! %bb.1: ! %entry
sub %o0, %o1, %o0
and %o1, %o0, %o0
sethi 122669, %o1
or %o1, 305, %o1
smul %o0, %o1, %o0
srl %o0, 27, %o0
sethi %hi(.LCPI0_0), %o1
add %o1, %lo(.LCPI0_0), %o1
add %o1, %o0, %o2
ldub [%o2+2], %o3
ldub [%o2+3], %o4
ldub [%o1+%o0], %o0
ldub [%o2+1], %o1
sll %o3, 8, %o2
or %o2, %o4, %o2
sll %o0, 8, %o0
or %o0, %o1, %o0
sll %o0, 16, %o0
or %o0, %o2, %o0
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128911/new/
https://reviews.llvm.org/D128911
More information about the llvm-commits
mailing list