diff options
| author | yingopq <115543042+yingopq@users.noreply.github.com> | 2026-02-11 16:27:57 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-11 16:27:57 +0800 |
| commit | 1e42c76d6133664b6b0a46e7844a27bb9ca6a45d (patch) | |
| tree | 01808a531a3bf2d2de268568dcc79efef643a25b /llvm/lib/CodeGen | |
| parent | ee92a9e1f4cb94f645243a90f864c46615aafcbf (diff) | |
| download | llvm-1e42c76d6133664b6b0a46e7844a27bb9ca6a45d.tar.gz llvm-1e42c76d6133664b6b0a46e7844a27bb9ca6a45d.tar.bz2 llvm-1e42c76d6133664b6b0a46e7844a27bb9ca6a45d.zip | |
[Mips] Fix cttz.i32 fails to lower on mips16 (#179633)
MIPS16 cannot handle constant pools created by CTTZ table lookup
expansion. This causes "Cannot select" errors when trying to select
MipsISD::Lo nodes for constant pool addresses.
Modify the table lookup conditions to check ConstantPool operation
status, and only set ConstantPool to Custom in non-MIPS16 mode in MIPS
backend.
This ensures MIPS16 uses the ISD::CTPOP instead of attempting
unsupported constant pool operations.
Fix #61055.
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index fd71cd846ed5..99968baec98e 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -9620,9 +9620,13 @@ SDValue TargetLowering::CTTZTableLookup(SDNode *Node, SelectionDAG &DAG, unsigned BitWidth) const { if (BitWidth != 32 && BitWidth != 64) return SDValue(); + + const DataLayout &TD = DAG.getDataLayout(); + if (!isOperationCustom(ISD::ConstantPool, getPointerTy(TD))) + return SDValue(); + APInt DeBruijn = BitWidth == 32 ? APInt(32, 0x077CB531U) : APInt(64, 0x0218A392CD3D5DBFULL); - const DataLayout &TD = DAG.getDataLayout(); MachinePointerInfo PtrInfo = MachinePointerInfo::getConstantPool(DAG.getMachineFunction()); unsigned ShiftAmt = BitWidth - Log2_32(BitWidth); |
