Commit 5ce0e197 by Uros Bizjak

re PR middle-end/35456 (Different results for inlined vs. non-inlined function)

	PR middle-end/35456
	* fold-const.c (fold_cond_expr_with_comparison): Prevent
	transformations for modes that have signed zeros.
	* ifcvt.c (noce_try_abs): Ditto.

testsuite/ChangeLog:

	PR middle-end/35456
	* gcc.c-torture/execute/pr35456.c: New test.

From-SVN: r132863
parent e0898f4c
2008-03-04 Uros Bizjak <ubizjak@gmail.com>
PR middle-end/35456
* fold-const.c (fold_cond_expr_with_comparison): Prevent
transformations for modes that have signed zeros.
* ifcvt.c (noce_try_abs): Ditto.
2008-03-04 Joseph Myers <joseph@codesourcery.com> 2008-03-04 Joseph Myers <joseph@codesourcery.com>
* config/i386/i386.c (override_options): Force * config/i386/i386.c (override_options): Force
...@@ -251,7 +258,8 @@ ...@@ -251,7 +258,8 @@
struct rdg_vertex_info, rdg_vertex_for_stmt): New. struct rdg_vertex_info, rdg_vertex_for_stmt): New.
(create_rdg_edge_for_ddr, create_rdg_vertices): Cleaned up. (create_rdg_edge_for_ddr, create_rdg_vertices): Cleaned up.
(stmts_from_loop): Skip LABEL_EXPR. (stmts_from_loop): Skip LABEL_EXPR.
(hash_stmt_vertex_info, eq_stmt_vertex_info, hash_stmt_vertex_del): New. (hash_stmt_vertex_info, eq_stmt_vertex_info, hash_stmt_vertex_del):
New.
(build_rdg): Initialize rdg->indices htab. (build_rdg): Initialize rdg->indices htab.
(free_rdg, stores_from_loop, ref_base_address, (free_rdg, stores_from_loop, ref_base_address,
rdg_defs_used_in_other_loops_p, have_similar_memory_accesses, rdg_defs_used_in_other_loops_p, have_similar_memory_accesses,
...@@ -260,7 +268,8 @@ ...@@ -260,7 +268,8 @@
* tree-data-ref.h: Depend on tree-chrec.h. * tree-data-ref.h: Depend on tree-chrec.h.
(debug_data_dependence_relations, free_data_ref): Declared. (debug_data_dependence_relations, free_data_ref): Declared.
(same_access_functions): ... here. (same_access_functions): ... here.
(ddr_is_anti_dependent, ddrs_have_anti_deps, ddr_dependence_level): New. (ddr_is_anti_dependent, ddrs_have_anti_deps, ddr_dependence_level):
New.
(struct rdg_vertex): Add has_mem_write and has_mem_reads. (struct rdg_vertex): Add has_mem_write and has_mem_reads.
(RDGV_HAS_MEM_WRITE, RDGV_HAS_MEM_READS, RDG_STMT, (RDGV_HAS_MEM_WRITE, RDGV_HAS_MEM_READS, RDG_STMT,
RDG_MEM_WRITE_STMT, RDG_MEM_READS_STMT): New. RDG_MEM_WRITE_STMT, RDG_MEM_READS_STMT): New.
...@@ -270,7 +279,8 @@ ...@@ -270,7 +279,8 @@
(struct rdg_edge): Add level. (struct rdg_edge): Add level.
(RDGE_LEVEL): New. (RDGE_LEVEL): New.
(free_rdg, stores_from_loop, remove_similar_memory_refs, (free_rdg, stores_from_loop, remove_similar_memory_refs,
rdg_defs_used_in_other_loops_p, have_similar_memory_accesses): Declared. rdg_defs_used_in_other_loops_p, have_similar_memory_accesses):
Declared.
(rdg_has_similar_memory_accesses): New. (rdg_has_similar_memory_accesses): New.
* tree-vect-analyze.c: Remove unused static decls. * tree-vect-analyze.c: Remove unused static decls.
* lambda.h (dependence_level): New. * lambda.h (dependence_level): New.
......
...@@ -5072,7 +5072,8 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) ...@@ -5072,7 +5072,8 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2)
Note that all these transformations are correct if A is Note that all these transformations are correct if A is
NaN, since the two alternatives (A and -A) are also NaNs. */ NaN, since the two alternatives (A and -A) are also NaNs. */
if ((FLOAT_TYPE_P (TREE_TYPE (arg01)) if (!HONOR_SIGNED_ZEROS (TYPE_MODE (type))
&& (FLOAT_TYPE_P (TREE_TYPE (arg01))
? real_zerop (arg01) ? real_zerop (arg01)
: integer_zerop (arg01)) : integer_zerop (arg01))
&& ((TREE_CODE (arg2) == NEGATE_EXPR && ((TREE_CODE (arg2) == NEGATE_EXPR
...@@ -5127,7 +5128,8 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) ...@@ -5127,7 +5128,8 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2)
both transformations are correct when A is NaN: A != 0 both transformations are correct when A is NaN: A != 0
is then true, and A == 0 is false. */ is then true, and A == 0 is false. */
if (integer_zerop (arg01) && integer_zerop (arg2)) if (!HONOR_SIGNED_ZEROS (TYPE_MODE (type))
&& integer_zerop (arg01) && integer_zerop (arg2))
{ {
if (comp_code == NE_EXPR) if (comp_code == NE_EXPR)
return pedantic_non_lvalue (fold_convert (type, arg1)); return pedantic_non_lvalue (fold_convert (type, arg1));
...@@ -5161,7 +5163,8 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) ...@@ -5161,7 +5163,8 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2)
a number and A is not. The conditions in the original a number and A is not. The conditions in the original
expressions will be false, so all four give B. The min() expressions will be false, so all four give B. The min()
and max() versions would give a NaN instead. */ and max() versions would give a NaN instead. */
if (operand_equal_for_comparison_p (arg01, arg2, arg00) if (!HONOR_SIGNED_ZEROS (TYPE_MODE (type))
&& operand_equal_for_comparison_p (arg01, arg2, arg00)
/* Avoid these transformations if the COND_EXPR may be used /* Avoid these transformations if the COND_EXPR may be used
as an lvalue in the C++ front-end. PR c++/19199. */ as an lvalue in the C++ front-end. PR c++/19199. */
&& (in_gimple_form && (in_gimple_form
......
...@@ -1738,6 +1738,10 @@ noce_try_abs (struct noce_if_info *if_info) ...@@ -1738,6 +1738,10 @@ noce_try_abs (struct noce_if_info *if_info)
rtx cond, earliest, target, seq, a, b, c; rtx cond, earliest, target, seq, a, b, c;
int negate; int negate;
/* Reject modes with signed zeros. */
if (HONOR_SIGNED_ZEROS (GET_MODE (if_info->x)))
return FALSE;
/* Recognize A and B as constituting an ABS or NABS. The canonical /* Recognize A and B as constituting an ABS or NABS. The canonical
form is a branch around the negation, taken when the object is the form is a branch around the negation, taken when the object is the
first operand of a comparison against 0 that evaluates to true. */ first operand of a comparison against 0 that evaluates to true. */
......
2008-03-04 Uros Bizjak <ubizjak@gmail.com>
PR middle-end/35456
* gcc.c-torture/execute/pr35456.c: New test.
2008-03-04 Joseph Myers <joseph@codesourcery.com> 2008-03-04 Joseph Myers <joseph@codesourcery.com>
* gcc.target/i386/sse-10.c: Don't use * gcc.target/i386/sse-10.c: Don't use
extern void abort (void);
double
__attribute__ ((noinline))
not_fabs (double x)
{
return x >= 0.0 ? x : -x;
}
int main()
{
double x = -0.0;
double y;
y = not_fabs (x);
if (!__builtin_signbit (y))
abort();
return 0;
}
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