https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81647
--- Comment #9 from sudi at gcc dot gnu.org --- Author: sudi Date: Mon Mar 19 18:50:32 2018 New Revision: 258653 URL: https://gcc.gnu.org/viewcvs?rev=258653&root=gcc&view=rev Log: [PR81647][AARCH64] Fix handling of Unordered Comparisons in aarch64-simd.md 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<cc> (a, b) -> UNORDERED (a, b) | (cm<cc> (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 <sudi....@arm.com> PR target/81647 * config/aarch64/aarch64-simd.md (vec_cmp<mode><v_int_equiv>): Modify instructions for UNLT, UNLE, UNGT, UNGE, UNEQ, UNORDERED and ORDERED. *** gcc/testsuite/ChangeLog *** 2018-03-19 Sudakshina Das <sudi....@arm.com> PR target/81647 * gcc.target/aarch64/pr81647.c: New. Added: trunk/gcc/testsuite/gcc.target/aarch64/pr81647.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/aarch64/aarch64-simd.md trunk/gcc/testsuite/ChangeLog