From: Richard Biener Date: Thu, 17 Apr 2014 08:13:53 +0000 (+0000) Subject: re PR tree-optimization/60849 (bogus comparison result type) X-Git-Tag: releases/gcc-5.1.0~8067 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=83ad208e2cd0f0d14e1f138598556a0a5a34764d;p=thirdparty%2Fgcc.git re PR tree-optimization/60849 (bogus comparison result type) 2014-04-17 Richard Biener PR middle-end/60849 * tree-ssa-propagate.c (valid_gimple_rhs_p): Only allow effective boolean results for comparisons. * g++.dg/opt/pr60849.C: New testcase. From-SVN: r209469 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index abfe3186d2e4..99ef2dc2ab86 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-04-17 Richard Biener + + PR middle-end/60849 + * tree-ssa-propagate.c (valid_gimple_rhs_p): Only allow effective + boolean results for comparisons. + 2014-04-17 Richard Biener PR tree-optimization/60836 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f180aef57a1e..67f8eef9c81d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-04-17 Richard Biener + + PR middle-end/60849 + * g++.dg/opt/pr60849.C: New testcase. + 2014-04-17 Richard Biener PR tree-optimization/60836 diff --git a/gcc/testsuite/g++.dg/opt/pr60849.C b/gcc/testsuite/g++.dg/opt/pr60849.C new file mode 100644 index 000000000000..52d8826b0c88 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr60849.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// { dg-options "-O2" } + +int g; + +extern "C" int isnan (); + +void foo(float a) { + int (*xx)(...); + xx = isnan; + if (xx(a)) + g++; +} diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index 840d7e76272a..47fd15455b25 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -571,8 +571,14 @@ valid_gimple_rhs_p (tree expr) /* All constants are ok. */ break; - case tcc_binary: case tcc_comparison: + if (!INTEGRAL_TYPE_P (TREE_TYPE (expr)) + || (TREE_CODE (TREE_TYPE (expr)) != BOOLEAN_TYPE + && TYPE_PRECISION (TREE_TYPE (expr)) != 1)) + return false; + + /* Fallthru. */ + case tcc_binary: if (!is_gimple_val (TREE_OPERAND (expr, 0)) || !is_gimple_val (TREE_OPERAND (expr, 1))) return false;