This is an archive of the discontinued LLVM Phabricator instance.

[ARM,MVE] Fix many signedness errors in MVE intrinsics.
ClosedPublic

Authored by simon_tatham on Jan 6 2020, 7:00 AM.

Details

Summary

Running an end-to-end test last week I noticed that a lot of the ACLE
intrinsics that operate differently on vectors of signed and unsigned
integers were ending up generating the signed version of the
instruction unconditionally. This is because the IR intrinsics had no
way to distinguish signed from unsigned: the LLVM type system just
calls them both v8i16 (or whatever), so you need either separate
intrinsics for signed and unsigned, or a flag parameter that tells
ISel which one to choose.

This patch fixes all the problems of that kind that I've noticed, by
adding an i32 flag parameter to many of the IR intrinsics which is set
to 1 for unsigned (matching the existing practice in cases where we
got it right), and conditioning all the isel patterns on that flag. So
the fundamental change is in IntrinsicsARM.td, changing the
low-level IR intrinsics API; there are knock-on changes in
arm_mve.td (adjusting code gen for the ACLE intrinsics to use the
modified API) and in ARMInstrMVE.td (adjusting isel to expect the
new unsigned flags). The rest of this patch is boringly updating tests.

Event Timeline

simon_tatham created this revision.Jan 6 2020, 7:00 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 6 2020, 7:00 AM
dmgreen added inline comments.Jan 6 2020, 8:13 AM
clang/include/clang/Basic/arm_mve.td
204

What do these 0's mean?

simon_tatham marked an inline comment as done.Jan 6 2020, 8:21 AM
simon_tatham added inline comments.
clang/include/clang/Basic/arm_mve.td
204

The IR intrinsic int_arm_mve_min_predicated is used for both integer min/max and floating-point minnm/maxnm. For the integer case it needs a signed/unsigned flag parameter; so it has to have that parameter in the floating-point case as well, even though there's nothing to distinguish.

dmgreen accepted this revision.Jan 6 2020, 8:29 AM

OK. LGTM then.

This revision is now accepted and ready to land.Jan 6 2020, 8:29 AM
This revision was automatically updated to reflect the committed changes.