This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[COMMITTED][GCC8][GCC9][AArch64] Backport PR81800
- From: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: nd <nd at arm dot com>
- Date: Wed, 4 Sep 2019 13:12:35 +0000
- Subject: [COMMITTED][GCC8][GCC9][AArch64] Backport PR81800
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QEoMfBIAUmWiRs+MmSUxnJ7VyCkBL/D7Bq0EauqvAP8=; b=UIrSXqonGHKV15lzlkdwhD2CCH1Ci29jGxI3IePhSeWtCBiePfJ6Ke20yDHXstUJwkIemvOXAQWCz2sP+2hmJuG5mVfE38TK7+yqz1Kg3Gr88CSMmwCKCIETSlvQbdRvcXTDkb8mMTq+oRgdZG1ODbrRug+J2SEMnZ1ojCEXmVk5gHTm18cmmEJV2WdUftLxvoYTyQpyKArhk2+pYAJcQ6CJd8PV/OJViYY8C3HCKpQnrixdTivuJUnuaWmvGS8MFEMwFRD9UnepHIKWHJ0Z6w6y3POVDCukicQ3/N/AfNMeZ4yVv2XzyL9cSueRTCi0J6uhPerchWpaJOtbuBGgPA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F0CRU/McZgMrQYFVyb6tzjRqi0lIGNvsgix6yo1D+TMn3aCnWg4hCGPZbAHJbMl3wTBVKBkF3RB4czA5VMAwYlIHoZFZBKXcFwoOyush0On44CXnHnwxUAZSVdcGOF4STbcyZdsmxNri4HkfpxstuKpUqhmPHNW0+oSLUkbUdXRirPL0JCbcZv82XobfOj9kzZPVlBUYP1P17ougLetT7LtH5yI+Ek6Rjjf9kKvlY++itnZ7pEOont5+kW3mZOCy9mzB9tYuP2oC851poksQiIArY19izqI1gYR7OAOuttlUp8ePqILTjZUg1tLIj8WDJ6YI0vGirkLcq9eIKKW6mg==
- Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco dot Dijkstra at arm dot com;
I've backported the fix for PR81800 to GCC8 and GCC9:
PR81800 is about the lrint inline giving spurious FE_INEXACT exceptions.
The previous change for PR81800 didn't fix this: when lrint is disabled
in the backend, the midend will simply use llrint. This actually makes
things worse since llrint now also ignores FE_INVALID exceptions!
The fix is to disable lrint/llrint on double if the size of a long is
smaller (ie. ilp32).
ChangeLog
2018-11-13 Wilco Dijkstra <wdijkstr@arm.com>
gcc/
PR target/81800
* gcc/config/aarch64/aarch64.md (lrint): Disable lrint pattern if GPF
operand is larger than a long int.
testsuite/
PR target/81800
* gcc.target/aarch64/no-inline-lrint_3.c: New test.
--
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 5a1894063a1ed2db1cc947c9c449d48808ed96ae..f08cd0930b3fc6527fbca218ad3c464f1ead0103 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -6304,7 +6304,7 @@ (define_expand "lrint<GPF:mode><GPI:mode>2"
[(match_operand:GPI 0 "register_operand")
(match_operand:GPF 1 "register_operand")]
"TARGET_FLOAT
- && ((GET_MODE_SIZE (<GPF:MODE>mode) <= GET_MODE_SIZE (<GPI:MODE>mode))
+ && ((GET_MODE_BITSIZE (<GPF:MODE>mode) <= LONG_TYPE_SIZE)
|| !flag_trapping_math || flag_fp_int_builtin_inexact)"
{
rtx cvt = gen_reg_rtx (<GPF:MODE>mode);
diff --git a/gcc/testsuite/gcc.target/aarch64/no-inline-lrint_3.c b/gcc/testsuite/gcc.target/aarch64/no-inline-lrint_3.c
new file mode 100644
index 0000000000000000000000000000000000000000..ca772cb999e7b6cfbd3f080111d3eb479d43f47b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/no-inline-lrint_3.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target ilp32 } */
+/* { dg-options "-O3 -fno-math-errno -fno-fp-int-builtin-inexact" } */
+
+#define TEST(name, float_type, int_type, fn) void f_##name (float_type x) \
+{ \
+ volatile int_type b = __builtin_##fn (x); \
+}
+
+TEST (dld, double, long, lrint)
+TEST (flf, float , long, lrintf)
+
+TEST (did, double, int, lrint)
+TEST (fif, float , int, lrintf)
+
+/* { dg-final { scan-assembler-times "fcvtzs\tw\[0-9\]+, \[d,s\]\[0-9\]+" 2 } } */
+/* { dg-final { scan-assembler-times "bl\tlrint" 2 } } */