[llvm] [DAGCombiner] Handle type-promoted constants in UDIV lowering (PR #169491)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 12 19:40:13 PST 2025
heiher wrote:
> We're hitting an assert after this change:
>
> ```
> llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:989: void (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(SDNode *): Assertion `(TLI.getTypeAction(*DAG.getContext(), Op.getValueType()) == TargetLowering::TypeLegal || Op.getOpcode() == ISD::TargetConstant || Op.getOpcode() == ISD::Register) && "Unexpected illegal type!"' failed.
> ```
We ran into the same issue on LoongArch, and here's a [reduced reproducer](https://github.com/llvm/llvm-project/issues/170976) that may help with the investigation.
After this PR, DAGCombiner ends up expanding `UDIV` after type legalization, introducing nodes that include logical right shifts on illegal types.
On the LoongArch side, we addressed this by implementing custom target-specific lowering for logical shift right nodes (https://github.com/llvm/llvm-project/pull/171097), preventing the generic DAG-level optimizations from generating such illegal constructs.
https://github.com/llvm/llvm-project/pull/169491
More information about the llvm-commits
mailing list