Page MenuHomePhabricator

[Constant] Allow ConstantAggregateZero a scalable element count
ClosedPublic

Authored by frasercrmck on May 7 2021, 10:12 AM.

Details

Summary

A ConstantAggregateZero may be created from a scalable vector type.
However, it still assumed fixed number of elements when queried for
them. This patch changes ConstantAggregateZero to correctly report its
element count.

This change fixes a couple of issues. Firstly, it fixes a crash in
Constant::getUniqueValue when called on a scalable-vector
zeroinitializer constant.

Secondly, it fixes a latent bug in GlobalISel's IRTranslator in which
translating a scalable-vector zeroinitializer would hit the assertion in
ConstantAggregateZero::getNumElements when casting to a FixedVectorType,
rather than reporting an error more gracefully. This is currently
hypothetical as the IRTranslator has deeper issues preventing the use of
scalable vector types.

Diff Detail

Event Timeline

frasercrmck created this revision.May 7 2021, 10:12 AM
frasercrmck requested review of this revision.May 7 2021, 10:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 7 2021, 10:12 AM
RKSimon accepted this revision.May 8 2021, 3:14 AM

LGTM

This revision is now accepted and ready to land.May 8 2021, 3:14 AM
  • rebase
  • appease clang-tidy
  • remove unnecessary cast to VectorType
RKSimon accepted this revision.May 10 2021, 4:17 AM

LGTM

This revision was landed with ongoing or failed builds.May 10 2021, 5:59 AM
This revision was automatically updated to reflect the committed changes.