[PR81647][AARCH64] Fix handling of Unordered Comparisons in aarch64-simd.md

Programming / Compilers / GCC - sudi [138bc75d-0d04-0410-961f-82ee72b054a4] - 19 March 2018 18:50 EDT

This patch fixes the inconsistent behavior observed at -O3 for the unordered comparisons. According to the online docs (https://gcc.gnu.org/onlinedocs /gcc-7.2.0/gccint/Unary-and-Binary-Expressions.html), all of the following should not raise an FP exception:- UNGE_EXPR- UNGT_EXPR- UNLE_EXPR- UNLT_EXPR- UNEQ_EXPR Also ORDERED_EXPR and UNORDERED_EXPR should only return zero or one.

The aarch64-simd.md handling of these were generating exception raising instructions such as fcmgt. This patch changes the instructions that are emitted in order to not give out the exceptions. We first check each operand for NaNs and force any elements containing NaN to zero before using them in the compare.

Example: UN (a, b) -> UNORDERED (a, b) | (cm (isnan (a) ? 0.0 : a, isnan (b) ? 0.0 : b))

The ORDERED_EXPR is now handled as (cmeq (a, a) & cmeq (b, b)) and UNORDERED_EXPR as ~ORDERED_EXPR and UNEQ as (~ORDERED_EXPR | cmeq (a,b)).

ChangeLog Entries:

*** gcc/ChangeLog ***

2018-03-19 Sudakshina Das

PR target/81647
- config/aarch64/aarch64-simd.md (vec_cmp): Modify instructions for UNLT, UNLE, UNGT, UNGE, UNEQ, UNORDERED and ORDERED.

*** gcc/testsuite/ChangeLog ***

2018-03-19 Sudakshina Das

PR target/81647
- gcc.target/aarch64/pr81647.c: New.

61d49d78e44 [PR81647][AARCH64] Fix handling of Unordered Comparisons in aarch64-simd.md
gcc/ChangeLog | 6 ++
gcc/config/aarch64/aarch64-simd.md | 103 +++++++++++++++++------------
gcc/testsuite/ChangeLog | 5 ++
gcc/testsuite/gcc.target/aarch64/pr81647.c | 44 ++++++++++++
4 files changed, 114 insertions(+), 44 deletions(-)

Upstream: gcc.gnu.org

  • Share