This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Explicitly widen non-power-of-2 vector HFA base types.
ClosedPublic

Authored by ab on Apr 11 2016, 5:11 PM.

Details

Summary

Currently, for the ppc64--gnu and aarch64 ABIs, we recognize:

typedef __attribute__((__ext_vector_type__(3))) float v3f32;
typedef __attribute__((__ext_vector_type__(16))) char v16i8;

struct HFA {
  v3f32 a;
  v16i8 b;
};

as an HFA. Since the base type is the first type encountered, we pass the HFA as:

[2 x <3 x float>]

Which leads to incorrect IR (relying on padding values) when the second field is used.

This patch teaches isHomogeneousAggregate to explicitly uses the widened vector (after size rounding).

I don't know if this approach is either sufficient or ideal; alternatives I considered:

  • pass as [2 x <3 x float>], but bitcast the struct pointer itself to [2 x <4 x float>]*; this still relies on accessing padding.
  • return an llvm::Type (instead of QualType) in isHomogeneousAggregate: there are a couple callers that rely on size/alignment info which should come from the clang::Type.
  • reject non-power-of-2 vectors as HFA base types: this doesn't make sense, as we treat them everywhere else as the next-power-of-2 type.
  • fixup the base type in the various isHomogeneousAggregate callers: repetitive changes all over the place.

Diff Detail

Event Timeline

ab updated this revision to Diff 53336.Apr 11 2016, 5:11 PM
ab retitled this revision from to [CodeGen] Explicitly widen non-power-of-2 vector HFA base types..
ab updated this object.
ab added reviewers: rjmccall, uweigand, t.p.northover.
ab added a subscriber: cfe-commits.
uweigand edited edge metadata.Apr 14 2016, 7:55 AM

Makes sense to me.

ab added a comment.Apr 19 2016, 10:12 AM

Thanks Ulrich. Tim?

t.p.northover accepted this revision.Apr 19 2016, 10:39 AM
t.p.northover edited edge metadata.

Sorry, I thought I'd already commented here. It looked good to me too.

Tim.

This revision is now accepted and ready to land.Apr 19 2016, 10:39 AM
This revision was automatically updated to reflect the committed changes.