public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-6861] tree-ssa-mathopts: Use proper poly_int64 comparison with param_avoid_fma_max_bits [PR 98766]
@ 2021-01-22 16:41 Kyrylo Tkachov
  0 siblings, 0 replies; only message in thread
From: Kyrylo Tkachov @ 2021-01-22 16:41 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9d33785f57daf29dc0c106c919da319fe1906bc6

commit r11-6861-g9d33785f57daf29dc0c106c919da319fe1906bc6
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date:   Thu Jan 21 16:33:49 2021 +0000

    tree-ssa-mathopts: Use proper poly_int64 comparison with param_avoid_fma_max_bits [PR 98766]
    
    We ICE here because we end up comparing a poly_int64 with a scalar using
    <= rather than maybe_le.
    This patch fixes that in the way rich suggests in the PR.
    
    gcc/ChangeLog:
    
            PR tree-optimization/98766
            * tree-ssa-math-opts.c (convert_mult_to_fma): Use maybe_le when
            comparing against type size with param_avoid_fma_max_bits.
    
    gcc/testsuite/ChangeLog:
    
            PR tree-optimization/98766
            * gcc.dg/pr98766.c: New test.

Diff:
---
 gcc/testsuite/gcc.dg/pr98766.c | 12 ++++++++++++
 gcc/tree-ssa-math-opts.c       |  4 ++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/pr98766.c b/gcc/testsuite/gcc.dg/pr98766.c
new file mode 100644
index 00000000000..d388fd2aa87
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr98766.c
@@ -0,0 +1,12 @@
+/* PR tree-optimization/98766.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O3 --param=avoid-fma-max-bits=8 " } */
+/* { dg-additional-options "-march=armv8.2-a+sve" { target aarch64*-*-* } } */
+
+extern int a[];
+void c(short *d) {
+  for (int e = 0; e < 9; e++)
+    a[e] = d[e] * 2;
+}
+
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index d6201d3cb94..c4a6492b50d 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -3252,8 +3252,8 @@ convert_mult_to_fma (gimple *mul_stmt, tree op1, tree op2,
 
   bool check_defer
     = (state->m_deferring_p
-       && (tree_to_shwi (TYPE_SIZE (type))
-	   <= param_avoid_fma_max_bits));
+       && maybe_le (tree_to_poly_int64 (TYPE_SIZE (type)),
+		    param_avoid_fma_max_bits));
   bool defer = check_defer;
   bool seen_negate_p = false;
   /* Make sure that the multiplication statement becomes dead after


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-22 16:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 16:41 [gcc r11-6861] tree-ssa-mathopts: Use proper poly_int64 comparison with param_avoid_fma_max_bits [PR 98766] Kyrylo Tkachov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).