This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][GlobalISel] Add a combine to fold away truncate in: G_ICMP EQ/NE (G_TRUNC(v), 0)
ClosedPublic

Authored by aemerson on Jan 28 2021, 3:48 PM.

Details

Summary

We try to do this optimization if we can determine that testing for the truncated bits with an eq/ne predicate results in the same thing as testing the lower bits.

Diff Detail

Event Timeline

aemerson created this revision.Jan 28 2021, 3:48 PM
aemerson requested review of this revision.Jan 28 2021, 3:48 PM

This is a pretty niche optimization, mostly to mitigate some regressions with a later patch, so it's AArch64 specific right now.

paquette accepted this revision.Jan 28 2021, 4:04 PM

This LGTM. Seems like it could be useful on other targets in general though.

llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp
68

Nit: ICmpInst has a helper for this

79

Minor nit: maybe slightly nicer to pull the other mi_match into here

if (!mi_match(...) || !mi_match(...))
  return false;
This revision is now accepted and ready to land.Jan 28 2021, 4:04 PM
This revision was landed with ongoing or failed builds.Jan 28 2021, 4:29 PM
This revision was automatically updated to reflect the committed changes.
foad added inline comments.Jan 29 2021, 2:58 AM
llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp
73

Is there any reason why this doesn't Just Work for vector types too?

80

There's also m_ZeroInt for this.

84

Could also do the optimisation if all the extended bits are known to be zero?