The following makes SCEV not throw FP expressions at tree-affine
which really isn't prepared for that.

Bootstrap & regtest running on x86_64-unknown-linux-gnu.

Richard.

2019-03-13  Richard Biener  <rguent...@suse.de>

        PR middle-end/89677
        * tree-scalar-evolution.c (simplify_peeled_chrec): Do not
        throw FP expressions at tree-affine.

        * gcc.dg/torture/pr89677.c: New testcase.

Index: gcc/tree-scalar-evolution.c
===================================================================
--- gcc/tree-scalar-evolution.c (revision 269383)
+++ gcc/tree-scalar-evolution.c (working copy)
@@ -1421,6 +1421,11 @@ simplify_peeled_chrec (struct loop *loop
       return build_polynomial_chrec (loop->num, init_cond, right);
     }
 
+  /* The affine code only deals with pointer and integer types.  */
+  if (!POINTER_TYPE_P (type)
+      && !INTEGRAL_TYPE_P (type))
+    return chrec_dont_know;
+
   /* Try harder to check if they are equal.  */
   tree_to_aff_combination_expand (left, type, &aff1, &peeled_chrec_map);
   tree_to_aff_combination_expand (step_val, type, &aff2, &peeled_chrec_map);
Index: gcc/testsuite/gcc.dg/torture/pr89677.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr89677.c      (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr89677.c      (working copy)
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target int32plus } */
+
+int a, b, d;
+unsigned c;
+float e, f, g;
+void h() {
+    float *i = &g;
+    for (; c < 10; c += 3)
+      for (; d; d += 3) {
+         a = *i;
+         g = f + 0;
+         f = b + *i + (b - e + 305219) + -b + 3;
+      }
+}

Reply via email to