This is an archive of the discontinued LLVM Phabricator instance.

[SDAG] Fold umul_lohi with 0 or 1 multiplicand
ClosedPublic

Authored by nikic on Aug 17 2019, 9:42 AM.

Details

Summary

These can turn up during multiplication legalization. In principle these should also apply to smul_lohi, but I wasn't able to figure out how to produce those.

Diff Detail

Repository
rL LLVM

Event Timeline

nikic created this revision.Aug 17 2019, 9:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2019, 9:42 AM
RKSimon added inline comments.Aug 18 2019, 4:45 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
4292 ↗(On Diff #215748)

Do we need a canonicalization of constants to the RHS?

nikic marked an inline comment as done.Aug 18 2019, 6:15 AM
nikic added inline comments.
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
4292 ↗(On Diff #215748)

Possibly, but no test case where this would be needed comes to mind. If we start from canonical IR we have constants on the RHS anyway, but even if we start from non-canonical IR, the constant will be moved to the RHS for ISD::MUL, before we get here. Possibly it could happen via UMULO, though in that case we should probably already canonicalize while it is a UMULO.

RKSimon accepted this revision.Aug 20 2019, 9:09 AM

OK, thanks for checking - LGTM

This revision is now accepted and ready to land.Aug 20 2019, 9:09 AM
This revision was automatically updated to reflect the committed changes.
llvm/trunk/test/CodeGen/X86/imul.ll