]> gcc.gnu.org Git - gcc.git/commitdiff
match.pd: Only merge truncation with conversion for -fno-signed-zeros
authorJoe Ramsay <Joe.Ramsay@arm.com>
Fri, 15 Mar 2024 09:20:45 +0000 (09:20 +0000)
committerTamar Christina <tamar.christina@arm.com>
Fri, 15 Mar 2024 09:21:13 +0000 (09:21 +0000)
This optimisation does not honour signed zeros, so should not be
enabled except with -fno-signed-zeros.

gcc/ChangeLog:

* match.pd: Fix truncation pattern for -fno-signed-zeroes

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/no_merge_trunc_signed_zero.c: New test.

gcc/match.pd
gcc/testsuite/gcc.target/aarch64/no_merge_trunc_signed_zero.c [new file with mode: 0644]

index 9ce313323a30082abdb5eea827a8d37d2e66ae7f..15a1e7350d4a896758204b00638b53e84045cb13 100644 (file)
@@ -4858,6 +4858,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 (simplify
    (float (fix_trunc @0))
    (if (!flag_trapping_math
+       && !HONOR_SIGNED_ZEROS (type)
        && types_match (type, TREE_TYPE (@0))
        && direct_internal_fn_supported_p (IFN_TRUNC, type,
                                          OPTIMIZE_FOR_BOTH))
diff --git a/gcc/testsuite/gcc.target/aarch64/no_merge_trunc_signed_zero.c b/gcc/testsuite/gcc.target/aarch64/no_merge_trunc_signed_zero.c
new file mode 100644 (file)
index 0000000..b2c93e5
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-trapping-math -fsigned-zeros" } */
+
+#include <math.h>
+
+float
+f1 (float x)
+{
+  return (int) rintf(x);
+}
+
+double
+f2 (double x)
+{
+  return (long) rint(x);
+}
+
+/* { dg-final { scan-assembler "frintx\\ts\[0-9\]+, s\[0-9\]+" } } */
+/* { dg-final { scan-assembler "cvtzs\\ts\[0-9\]+, s\[0-9\]+" } } */
+/* { dg-final { scan-assembler "scvtf\\ts\[0-9\]+, s\[0-9\]+" } } */
+/* { dg-final { scan-assembler "frintx\\td\[0-9\]+, d\[0-9\]+" } } */
+/* { dg-final { scan-assembler "cvtzs\\td\[0-9\]+, d\[0-9\]+" } } */
+/* { dg-final { scan-assembler "scvtf\\td\[0-9\]+, d\[0-9\]+" } } */
+
This page took 0.086813 seconds and 5 git commands to generate.