This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] don't canonicalize shl+sub to mul+add
ClosedPublic

Authored by spatel on Sep 20 2022, 1:39 PM.

Details

Summary

This stops Negator from transforming:
C1 - shl X, C2 --> mul X, (1<<C2) + C1
...in the general case. There does not seem to be any analysis benefit to using mul in IR, and there's definitely downside in codegen (particularly when the multiply has to be expanded).

If C1 is 0, then there's a stronger argument that the single mul is a better canonicalization than negate-of-shl, but we may want to remove that too.

This was noted as a potential conflict for D133667.

Diff Detail