diff mbox

[PR81799] Fix ICE by forcing to is_gimple_val

Message ID DB5PR0801MB274278EB7FC98AD6B6499DC8E78C0@DB5PR0801MB2742.eurprd08.prod.outlook.com
State New
Headers show

Commit Message

Bin Cheng Aug. 14, 2017, 11:05 a.m. UTC
Hi,
This patch fixes ICE reported in PR81799.  It simply uses is_gimple_val rather than is_gimple_condexpr.
Bootstap and test on x86_64.  Is it OK?

Thanks,
bin
2017-08-11  Bin Cheng  <bin.cheng@arm.com>

	PR tree-optimization/81799
	* tree-loop-distribution.c (version_loop_by_alias_check): Force
	cond_expr to simple gimple operand.

gcc/testsuite
2017-08-11  Bin Cheng  <bin.cheng@arm.com>

	PR tree-optimization/81799
	* gcc.dg/tree-ssa/pr81799.c: New.

Comments

Richard Biener Aug. 14, 2017, 11:21 a.m. UTC | #1
On Mon, Aug 14, 2017 at 1:05 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> This patch fixes ICE reported in PR81799.  It simply uses is_gimple_val rather than is_gimple_condexpr.
> Bootstap and test on x86_64.  Is it OK?

I guess this eventually pessimizes code-gen for the case we do not
have the IFN call (eventually cleaned up
by folding / forwprop later).

I guess we don't care too much and thus OK.

Thanks,
Richard.

> Thanks,
> bin
> 2017-08-11  Bin Cheng  <bin.cheng@arm.com>
>
>         PR tree-optimization/81799
>         * tree-loop-distribution.c (version_loop_by_alias_check): Force
>         cond_expr to simple gimple operand.
>
> gcc/testsuite
> 2017-08-11  Bin Cheng  <bin.cheng@arm.com>
>
>         PR tree-optimization/81799
>         * gcc.dg/tree-ssa/pr81799.c: New.
Bin.Cheng Aug. 14, 2017, 11:28 a.m. UTC | #2
On Mon, Aug 14, 2017 at 12:21 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Mon, Aug 14, 2017 at 1:05 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
>> Hi,
>> This patch fixes ICE reported in PR81799.  It simply uses is_gimple_val rather than is_gimple_condexpr.
>> Bootstap and test on x86_64.  Is it OK?
>
> I guess this eventually pessimizes code-gen for the case we do not
> have the IFN call (eventually cleaned up
> by folding / forwprop later).
Note we are not optimal with current code even folding/forwprop can
fold condition to true/false because we undo the versioning in
vectorizer and the folding is not happening between distribution and
vectorizer?

Thanks,
bin
>
> I guess we don't care too much and thus OK.
>
> Thanks,
> Richard.
>
>> Thanks,
>> bin
>> 2017-08-11  Bin Cheng  <bin.cheng@arm.com>
>>
>>         PR tree-optimization/81799
>>         * tree-loop-distribution.c (version_loop_by_alias_check): Force
>>         cond_expr to simple gimple operand.
>>
>> gcc/testsuite
>> 2017-08-11  Bin Cheng  <bin.cheng@arm.com>
>>
>>         PR tree-optimization/81799
>>         * gcc.dg/tree-ssa/pr81799.c: New.
diff mbox

Patch

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81799.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81799.c
new file mode 100644
index 0000000..aad01232
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr81799.c
@@ -0,0 +1,25 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+int printf (const char *, ...);
+
+int a, c[1], d, e, **f;
+
+void fn1 (int h)
+{
+  int *i = 0;
+  for (d = 0; d < 1; d++)
+    {
+      if (d)
+        continue;
+      for (; e; e++)
+        {
+          a = c[*i];
+          if (h)
+            printf ("0");
+        }
+      return;
+    }
+  f = &i;
+}
+
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 8d80ccc..b1b2934 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -2263,7 +2263,7 @@  version_loop_by_alias_check (struct loop *loop, vec<ddr_p> *alias_ddrs)
   compute_alias_check_pairs (loop, alias_ddrs, &comp_alias_pairs);
   create_runtime_alias_checks (loop, &comp_alias_pairs, &cond_expr);
   cond_expr = force_gimple_operand_1 (cond_expr, &cond_stmts,
-				      is_gimple_condexpr, NULL_TREE);
+				      is_gimple_val, NULL_TREE);
 
   /* Depend on vectorizer to fold IFN_LOOP_DIST_ALIAS.  */
   if (flag_tree_loop_vectorize)