This is an archive of the discontinued LLVM Phabricator instance.

[ARM][ARMCGP] Remove unecessary zexts and truncs
ClosedPublic

Authored by samparker on Nov 2 2018, 3:39 AM.

Details

Summary

r345840 slightly changed the way promotion happens which could result in zext and truncs having the same source and destination types. This fixes that issue.

We can now also remove the zext and trunc in the following case:
(zext (trunc (promoted op)), i32)

This means that we can no longer treat a value, that is only used by a sink, to be safe to promote.

I've also added in some extra asserts and replaced a cast for a dyn_cast.

Diff Detail

Repository
rL LLVM

Event Timeline

samparker created this revision.Nov 2 2018, 3:39 AM
samparker updated this revision to Diff 172365.Nov 2 2018, 8:22 AM
samparker retitled this revision from [ARM] Add some asserts to ARMCGP to [ARM][ARMCGP] Remove unecessary zexts and truncs.
samparker edited the summary of this revision. (Show Details)

Fixed a bug that allowed zext to be generated with the same source and destination types.

SjoerdMeijer accepted this revision.Nov 5 2018, 2:41 AM

LGTM

lib/Target/ARM/ARMCodeGenPrepare.cpp
674 ↗(On Diff #172365)

Nit, instead of:

if (NewInsts.count(Src) && isa<TruncInst>(Src)) {
  auto *Trunc = cast<TruncInst>(Src);
  ...

perhaps this?

auto *Trunc = cast<TruncInst>(Src);
if (NewInsts.count(Src) && Trunc) {
  ...
984 ↗(On Diff #172365)

What is this dbgs(); doing? I guess it's not doing much, and a left over from a previous clean-up.

This revision is now accepted and ready to land.Nov 5 2018, 2:41 AM
This revision was automatically updated to reflect the committed changes.