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
This commit is contained in:
Uros Bizjak 2008-03-04 14:57:27 +01:00
parent e0898f4ced
commit 5ce0e19775
5 changed files with 51 additions and 8 deletions

View File

@ -1,3 +1,10 @@
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>
* config/i386/i386.c (override_options): Force
@ -251,7 +258,8 @@
struct rdg_vertex_info, rdg_vertex_for_stmt): New.
(create_rdg_edge_for_ddr, create_rdg_vertices): Cleaned up.
(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.
(free_rdg, stores_from_loop, ref_base_address,
rdg_defs_used_in_other_loops_p, have_similar_memory_accesses,
@ -260,7 +268,8 @@
* tree-data-ref.h: Depend on tree-chrec.h.
(debug_data_dependence_relations, free_data_ref): Declared.
(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.
(RDGV_HAS_MEM_WRITE, RDGV_HAS_MEM_READS, RDG_STMT,
RDG_MEM_WRITE_STMT, RDG_MEM_READS_STMT): New.
@ -270,7 +279,8 @@
(struct rdg_edge): Add level.
(RDGE_LEVEL): New.
(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.
* tree-vect-analyze.c: Remove unused static decls.
* lambda.h (dependence_level): New.

View File

@ -5072,9 +5072,10 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2)
Note that all these transformations are correct if A is
NaN, since the two alternatives (A and -A) are also NaNs. */
if ((FLOAT_TYPE_P (TREE_TYPE (arg01))
? real_zerop (arg01)
: integer_zerop (arg01))
if (!HONOR_SIGNED_ZEROS (TYPE_MODE (type))
&& (FLOAT_TYPE_P (TREE_TYPE (arg01))
? real_zerop (arg01)
: integer_zerop (arg01))
&& ((TREE_CODE (arg2) == NEGATE_EXPR
&& operand_equal_p (TREE_OPERAND (arg2, 0), arg1, 0))
/* In the case that A is of the form X-Y, '-A' (arg2) may
@ -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
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)
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)
a number and A is not. The conditions in the original
expressions will be false, so all four give B. The min()
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
as an lvalue in the C++ front-end. PR c++/19199. */
&& (in_gimple_form

View File

@ -1738,6 +1738,10 @@ noce_try_abs (struct noce_if_info *if_info)
rtx cond, earliest, target, seq, a, b, c;
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
form is a branch around the negation, taken when the object is the
first operand of a comparison against 0 that evaluates to true. */

View File

@ -1,3 +1,8 @@
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>
* gcc.target/i386/sse-10.c: Don't use

View File

@ -0,0 +1,21 @@
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;
}