This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Combine (0 * x) -> 0
AbandonedPublic

Authored by paquette on Jun 15 2020, 1:48 PM.

Details

Reviewers
aemerson
arsenm
Summary

Before, we only folded (x * 0) -> 0. It's possible that the 0 can show up on the RHS instead of the LHS. (E.g. inlining a memset and getting a multiply of two constants.)

So, let's fold 0 on the LHS as well.

Example: https://godbolt.org/z/CHQVs9

Diff Detail

Event Timeline

paquette created this revision.Jun 15 2020, 1:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2020, 1:48 PM
Herald added subscribers: rovka, wdng. · View Herald Transcript

We're missing the canonicalizations in MIR. It would be better to fix that instead?

aemerson accepted this revision.Jun 15 2020, 3:05 PM

LGTM but I think this is unnecessary since it was a simple fix to just avoid generating useless multiplies in fc905ae003df

Feel free to commit anyway.

This revision is now accepted and ready to land.Jun 15 2020, 3:05 PM
arsenm requested changes to this revision.Jun 15 2020, 3:32 PM
This revision now requires changes to proceed.Jun 15 2020, 3:32 PM
paquette abandoned this revision.Jun 15 2020, 4:25 PM

I think I'd rather take the canonicalization route. I'll drop this so we can do this the right way.