Commit 08d19889 by Kaveh R. Ghazi Committed by Kaveh Ghazi

re PR tree-optimization/41987 (expected class ‘constant’, have ‘binary’…

re PR tree-optimization/41987 (expected class ‘constant’, have ‘binary’ (rdiv_expr) in build_complex, at tree.c:1485)

	PR tree-optimization/41987
	* fold-const.c (const_binop): Avoid using fold_buildN().

testsuite:
	* gcc.c-torture/compile/pr41987.c: New.

From-SVN: r154065
parent 2c5721d9
2009-11-10 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
PR tree-optimization/41987
* fold-const.c (const_binop): Avoid using fold_buildN().
2009-11-10 Martin Jambor <mjambor@suse.cz> 2009-11-10 Martin Jambor <mjambor@suse.cz>
* tree-pass.h (struct ipa_opt_pass_d): Added stmt_fixup field. * tree-pass.h (struct ipa_opt_pass_d): Added stmt_fixup field.
...@@ -2031,10 +2031,10 @@ const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc) ...@@ -2031,10 +2031,10 @@ const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc)
Expand complex division to scalars, modified algorithm to minimize Expand complex division to scalars, modified algorithm to minimize
overflow with wide input ranges. */ overflow with wide input ranges. */
tree inner_type = TREE_TYPE (type); tree compare = fold_build2 (LT_EXPR, boolean_type_node,
tree absr2 = fold_build1 (ABS_EXPR, inner_type, r2); fold_abs_const (r2, TREE_TYPE (type)),
tree absi2 = fold_build1 (ABS_EXPR, inner_type, i2); fold_abs_const (i2, TREE_TYPE (type)));
tree compare = fold_build2 (LT_EXPR, boolean_type_node, absr2, absi2);
if (integer_nonzerop (compare)) if (integer_nonzerop (compare))
{ {
/* In the TRUE branch, we compute /* In the TRUE branch, we compute
...@@ -2044,17 +2044,18 @@ const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc) ...@@ -2044,17 +2044,18 @@ const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc)
ti = (ai * ratio) - ar; ti = (ai * ratio) - ar;
tr = tr / div; tr = tr / div;
ti = ti / div; */ ti = ti / div; */
tree ratio = fold_build2 (code, inner_type, r2, i2); tree ratio = const_binop (code, r2, i2, notrunc);
tree div = fold_build2 (PLUS_EXPR, inner_type, i2, tree div = const_binop (PLUS_EXPR, i2,
fold_build2 (MULT_EXPR, inner_type, const_binop (MULT_EXPR, r2, ratio,
r2, ratio)); notrunc),
real = fold_build2 (MULT_EXPR, inner_type, r1, ratio); notrunc);
real = fold_build2 (PLUS_EXPR, inner_type, real, i1); real = const_binop (MULT_EXPR, r1, ratio, notrunc);
real = fold_build2 (code, inner_type, real, div); real = const_binop (PLUS_EXPR, real, i1, notrunc);
real = const_binop (code, real, div, notrunc);
imag = fold_build2 (MULT_EXPR, inner_type, i1, ratio);
imag = fold_build2 (MINUS_EXPR, inner_type, imag, r1); imag = const_binop (MULT_EXPR, i1, ratio, notrunc);
imag = fold_build2 (code, inner_type, imag, div); imag = const_binop (MINUS_EXPR, imag, r1, notrunc);
imag = const_binop (code, imag, div, notrunc);
} }
else else
{ {
...@@ -2065,18 +2066,19 @@ const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc) ...@@ -2065,18 +2066,19 @@ const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc)
ti = b - (a * ratio); ti = b - (a * ratio);
tr = tr / div; tr = tr / div;
ti = ti / div; */ ti = ti / div; */
tree ratio = fold_build2 (code, inner_type, i2, r2); tree ratio = const_binop (code, i2, r2, notrunc);
tree div = fold_build2 (PLUS_EXPR, inner_type, r2, tree div = const_binop (PLUS_EXPR, r2,
fold_build2 (MULT_EXPR, inner_type, const_binop (MULT_EXPR, i2, ratio,
i2, ratio)); notrunc),
notrunc);
real = fold_build2 (MULT_EXPR, inner_type, i1, ratio);
real = fold_build2 (PLUS_EXPR, inner_type, real, r1); real = const_binop (MULT_EXPR, i1, ratio, notrunc);
real = fold_build2 (code, inner_type, real, div); real = const_binop (PLUS_EXPR, real, r1, notrunc);
real = const_binop (code, real, div, notrunc);
imag = fold_build2 (MULT_EXPR, inner_type, r1, ratio);
imag = fold_build2 (MINUS_EXPR, inner_type, i1, imag); imag = const_binop (MULT_EXPR, r1, ratio, notrunc);
imag = fold_build2 (code, inner_type, imag, div); imag = const_binop (MINUS_EXPR, i1, imag, notrunc);
imag = const_binop (code, imag, div, notrunc);
} }
} }
break; break;
......
2009-11-10 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.c-torture/compile/pr41987.c: New.
2009-11-09 Jakub Jelinek <jakub@redhat.com> 2009-11-09 Jakub Jelinek <jakub@redhat.com>
PR middle-end/40946 PR middle-end/40946
......
/* PR tree-optimization/41987 */
#define TESTIT(TYPE) do { \
_Complex TYPE ylm; \
TYPE nbond; \
ylm = 0; \
nbond = 0; \
ylm = ylm / nbond; \
} while (0)
void qparm_colvar(void)
{
TESTIT (float);
TESTIT (double);
TESTIT (long double);
TESTIT (char);
TESTIT (short);
TESTIT (int);
TESTIT (long);
TESTIT (long long);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment