This is an archive of the discontinued LLVM Phabricator instance.

[AIX] Use posix_memalign instead of malloc to ensure 16 byte alignment
ClosedPublic

Authored by ZarkoCA on Jun 2 2021, 1:21 PM.

Details

Summary

On AIX in 32bit mode, malloc may not be 16 byte aligned as required for vector
data types. This causes these test cases to generate incorrect output.
Using posix_memalign instead we ensure 16 byte alignment in 64 and
32 bit mode and correct output.

Diff Detail

Event Timeline

ZarkoCA requested review of this revision.Jun 2 2021, 1:21 PM
ZarkoCA created this revision.
bmahjour added inline comments.Jun 2 2021, 2:08 PM
SingleSource/UnitTests/Vector/Altivec/alti.expandfft.c
38

The alignment requirements for the VMX instructions are OS-agnostic, so ideally we should just replace malloc with posix_memalign (without checking for AIX). I believe this test runs only on PPC platforms, so should be safe to change.

ZarkoCA updated this revision to Diff 349386.Jun 2 2021, 2:45 PM

Remove AIX check for posix_memalign and use across platforms.

ZarkoCA marked an inline comment as done.Jun 2 2021, 2:50 PM
ZarkoCA added inline comments.
SingleSource/UnitTests/Vector/Altivec/alti.expandfft.c
38

I had read that Mac OS/X doesn't support posix_memalign and wanted to be conservative with the change. But, AFAIK, we don't even support that platform anymore on PPC, so yes, it should be safe to change for all PPC platforms.

LGTM

SingleSource/UnitTests/Vector/Altivec/alti.expandfft.c
38

Tried on my Mac (Darwin Kernel Version 20.4.0) and it worked. In any case, if some OS shows a failure, we could go back and guard those ones.

bmahjour accepted this revision.Jun 2 2021, 5:22 PM
This revision is now accepted and ready to land.Jun 2 2021, 5:22 PM