mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-03 21:51:45 +08:00
re PR middle-end/38932 (ICE in set_value_range, at tree-vrp.c:398)
2008-01-23 Paolo Bonzini <bonzini@gnu.org> PR tree-optimization/38932 * fold-const.c (fold_unary_no_overflow): New. * tree.h (fold_unary_no_overflow): Declare. * tree-ssa-ccp.c (ccp_fold): Use fold_unary_no_overflow. * tree-ssa-sccvn.c (visit_reference_op_load, simplify_unary_expression): Likewise. testsuite: 2008-01-23 Paolo Bonzini <bonzini@gnu.org> PR tree-optimization/38932 * gcc.dg/pr38932.c: New. From-SVN: r143588
This commit is contained in:
parent
63e505333c
commit
9bacafeb4c
@ -1,3 +1,12 @@
|
||||
2008-01-23 Paolo Bonzini <bonzini@gnu.org>
|
||||
|
||||
PR tree-optimization/38932
|
||||
* fold-const.c (fold_unary_ignore_overflow): New.
|
||||
* tree.h (fold_unary_ignore_overflow): Declare.
|
||||
* tree-ssa-ccp.c (ccp_fold): Use fold_unary_ignore_overflow.
|
||||
* tree-ssa-sccvn.c (visit_reference_op_load,
|
||||
simplify_unary_expression): Likewise.
|
||||
|
||||
2009-01-22 Adam Nemet <anemet@caviumnetworks.com>
|
||||
|
||||
* c-decl.c (finish_struct): Move code to set DECL_PACKED after
|
||||
|
@ -8628,6 +8628,24 @@ fold_unary (enum tree_code code, tree type, tree op0)
|
||||
} /* switch (code) */
|
||||
}
|
||||
|
||||
|
||||
/* If the operation was a conversion do _not_ mark a resulting constant
|
||||
with TREE_OVERFLOW if the original constant was not. These conversions
|
||||
have implementation defined behavior and retaining the TREE_OVERFLOW
|
||||
flag here would confuse later passes such as VRP. */
|
||||
tree
|
||||
fold_unary_ignore_overflow (enum tree_code code, tree type, tree op0)
|
||||
{
|
||||
tree res = fold_unary (code, type, op0);
|
||||
if (res
|
||||
&& TREE_CODE (res) == INTEGER_CST
|
||||
&& TREE_CODE (op0) == INTEGER_CST
|
||||
&& CONVERT_EXPR_CODE_P (code))
|
||||
TREE_OVERFLOW (res) = TREE_OVERFLOW (op0);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Fold a binary expression of code CODE and type TYPE with operands
|
||||
OP0 and OP1, containing either a MIN-MAX or a MAX-MIN combination.
|
||||
Return the folded expression if folding is successful. Otherwise,
|
||||
|
@ -1,3 +1,8 @@
|
||||
2008-01-23 Paolo Bonzini <bonzini@gnu.org>
|
||||
|
||||
PR tree-optimization/38932
|
||||
* gcc.dg/pr38932.c: New.
|
||||
|
||||
2009-01-23 Revital Eres <eres@il.ibm.com>
|
||||
|
||||
* gcc.dg/sms-7.c: Fix test.
|
||||
|
19
gcc/testsuite/gcc.dg/pr38932.c
Normal file
19
gcc/testsuite/gcc.dg/pr38932.c
Normal file
@ -0,0 +1,19 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2" } */
|
||||
|
||||
/* This variable needed only to exercise FRE instead of CCP. */
|
||||
unsigned char g;
|
||||
|
||||
extern void abort();
|
||||
|
||||
void f (long long int p)
|
||||
{
|
||||
g = 255;
|
||||
if (p >= (-9223372036854775807LL - 1) - (signed char) g)
|
||||
p = 1;
|
||||
|
||||
if (p)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
@ -966,7 +966,6 @@ ccp_fold (gimple stmt)
|
||||
so this should almost always return a simplified RHS. */
|
||||
tree lhs = gimple_assign_lhs (stmt);
|
||||
tree op0 = gimple_assign_rhs1 (stmt);
|
||||
tree res;
|
||||
|
||||
/* Simplify the operand down to a constant. */
|
||||
if (TREE_CODE (op0) == SSA_NAME)
|
||||
@ -1002,20 +1001,8 @@ ccp_fold (gimple stmt)
|
||||
return op0;
|
||||
}
|
||||
|
||||
res = fold_unary (subcode, gimple_expr_type (stmt), op0);
|
||||
|
||||
/* If the operation was a conversion do _not_ mark a
|
||||
resulting constant with TREE_OVERFLOW if the original
|
||||
constant was not. These conversions have implementation
|
||||
defined behavior and retaining the TREE_OVERFLOW flag
|
||||
here would confuse later passes such as VRP. */
|
||||
if (res
|
||||
&& TREE_CODE (res) == INTEGER_CST
|
||||
&& TREE_CODE (op0) == INTEGER_CST
|
||||
&& CONVERT_EXPR_CODE_P (subcode))
|
||||
TREE_OVERFLOW (res) = TREE_OVERFLOW (op0);
|
||||
|
||||
return res;
|
||||
return fold_unary_ignore_overflow (subcode,
|
||||
gimple_expr_type (stmt), op0);
|
||||
}
|
||||
|
||||
case GIMPLE_BINARY_RHS:
|
||||
|
@ -1761,7 +1761,8 @@ visit_reference_op_load (tree lhs, tree op, gimple stmt)
|
||||
tree tem = valueize_expr (vn_get_expr_for (TREE_OPERAND (val, 0)));
|
||||
if ((CONVERT_EXPR_P (tem)
|
||||
|| TREE_CODE (tem) == VIEW_CONVERT_EXPR)
|
||||
&& (tem = fold_unary (TREE_CODE (val), TREE_TYPE (val), tem)))
|
||||
&& (tem = fold_unary_ignore_overflow (TREE_CODE (val),
|
||||
TREE_TYPE (val), tem)))
|
||||
val = tem;
|
||||
}
|
||||
result = val;
|
||||
@ -2123,7 +2124,7 @@ simplify_binary_expression (gimple stmt)
|
||||
fold_defer_overflow_warnings ();
|
||||
|
||||
result = fold_binary (gimple_assign_rhs_code (stmt),
|
||||
TREE_TYPE (gimple_get_lhs (stmt)), op0, op1);
|
||||
TREE_TYPE (gimple_get_lhs (stmt)), op0, op1);
|
||||
if (result)
|
||||
STRIP_USELESS_TYPE_CONVERSION (result);
|
||||
|
||||
@ -2182,8 +2183,8 @@ simplify_unary_expression (gimple stmt)
|
||||
if (op0 == orig_op0)
|
||||
return NULL_TREE;
|
||||
|
||||
result = fold_unary (gimple_assign_rhs_code (stmt),
|
||||
gimple_expr_type (stmt), op0);
|
||||
result = fold_unary_ignore_overflow (gimple_assign_rhs_code (stmt),
|
||||
gimple_expr_type (stmt), op0);
|
||||
if (result)
|
||||
{
|
||||
STRIP_USELESS_TYPE_CONVERSION (result);
|
||||
|
@ -4733,6 +4733,7 @@ extern tree native_interpret_expr (tree, const unsigned char *, int);
|
||||
|
||||
extern tree fold (tree);
|
||||
extern tree fold_unary (enum tree_code, tree, tree);
|
||||
extern tree fold_unary_ignore_overflow (enum tree_code, tree, tree);
|
||||
extern tree fold_binary (enum tree_code, tree, tree, tree);
|
||||
extern tree fold_ternary (enum tree_code, tree, tree, tree, tree);
|
||||
extern tree fold_build1_stat (enum tree_code, tree, tree MEM_STAT_DECL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user