tree-ssa-mathopts: Use proper poly_int64 comparison with param_avoid_fma_max_bits...
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Thu, 21 Jan 2021 16:33:49 +0000 (16:33 +0000)
committerKyrylo Tkachov <kyrylo.tkachov@arm.com>
Fri, 22 Jan 2021 16:40:57 +0000 (16:40 +0000)
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.

gcc/testsuite/gcc.dg/pr98766.c [new file with mode: 0644]
gcc/tree-ssa-math-opts.c

diff --git a/gcc/testsuite/gcc.dg/pr98766.c b/gcc/testsuite/gcc.dg/pr98766.c
new file mode 100644 (file)
index 0000000..d388fd2
--- /dev/null
@@ -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;
+}
+
index d6201d3cb943e145720c18fbf3aadd853fd87b44..c4a6492b50df25b4cf296a75bd51e5af34eeacc7 100644 (file)
@@ -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