[PATCH] D128911: Emit table lookup from TargetLowering::expandCTTZ()
Shubham Narlawar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 1 04:41:09 PDT 2022
gsocshubham added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:7984
+ CA, getPointerTy(TD),
+ TD.getPrefTypeAlign(VT.getTypeForEVT(*DAG.getContext())));
+ Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
----------------
craig.topper wrote:
> Replace VT.getTypeForEVT(*DAG.getContext()) with `CA->getType()`
If I change alignment as above, then for `call i32 @llvm.cttz.i32(i32 %x, i1 true)` compiled with SPARC -
I get -
```
f: ! @f
.cfi_startproc
! %bb.0: ! %entry
mov %g0, %o1
sub %o1, %o0, %o1
and %o0, %o1, %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
retl
or %o0, %o2, %o0
```
instead of -
```
mov %g0, %o1
sub %o1, %o0, %o1
and %o0, %o1, %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
retl
ld [%o1+%o0], %o0
```
================
Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:7986
+ Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
+ SDValue Load = DAG.getLoad(
+ VT, dl, DAG.getEntryNode(),
----------------
craig.topper wrote:
> What happens if you always create a zextload even if the type isn't legal?
There is no change in generated code nor in LIT test failures as it was originally submitted earlier.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128911/new/
https://reviews.llvm.org/D128911
More information about the llvm-commits
mailing list