This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen][ARM] Fix FP16 vector coercion
ClosedPublic

Authored by miyuki on Jun 17 2019, 8:46 AM.

Details

Summary

When a function argument or return type is a homogeneous aggregate
which contains an FP16 vector but the target does not support FP16
operations natively, the type must be converted into an array of
integer vectors by then front end (otherwise LLVM will handle FP16
vectors incorrectly by scalarizing them and promoting FP16 to float,
see https://reviews.llvm.org/D50507).

Currently the logic for checking whether or not a given homogeneous
aggregate contains FP16 vectors is incorrect: it only looks at the
type of the first vector.

This patch fixes the issue by adding a new method
ARMABIInfo::containsAnyFP16Vectors and using it. The traversal logic
of this method is largely the same as in
ABIInfo::isHomogeneousAggregate.

Diff Detail

Repository
rL LLVM

Event Timeline

miyuki created this revision.Jun 17 2019, 8:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 17 2019, 8:46 AM

This doesn't look like the right pace to fix this - the backend can handle vectors of i8 and i16, which are also not legal types, so why can't it correctly handle vectors of f16?

This doesn't look like the right pace to fix this - the backend can handle vectors of i8 and i16, which are also not legal types, so why can't it correctly handle vectors of f16?

IIRC, we decided to handle this in the frontend for consistency with scalar fp16 handling: https://reviews.llvm.org/D49987

ostannard accepted this revision.Jun 18 2019, 7:14 AM

Ah, right. In that case, this LGTM.

This revision is now accepted and ready to land.Jun 18 2019, 7:14 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 18 2019, 7:35 AM