aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2011-10-23 15:57:09 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2011-10-23 15:57:09 +0000
commit4db183a2d5c98d60144b88dcf402f06fc2103200 (patch)
treee71fcaef7ab6dc1b0e93c1f57a474e7fe80156e3 /gcc
parentd621a5fb6d9bd91e30e96ba9ee60ac8ec1350ee1 (diff)
downloadgcc-4db183a2d5c98d60144b88dcf402f06fc2103200.zip
gcc-4db183a2d5c98d60144b88dcf402f06fc2103200.tar.gz
gcc-4db183a2d5c98d60144b88dcf402f06fc2103200.tar.bz2
re PR tree-optimization/44683 (Optimization bug with copysign builtin)
* fold-const.c (invert_tree_comparison): Always invert EQ_EXPR/NE_EXPR. PR tree-optimization/44683 * tree-ssa-dom.c (record_edge_info): Record simple equivalences only if we can be sure that there are no signed zeros involved. From-SVN: r180340
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/fold-const.c9
-rw-r--r--gcc/tree-ssa-dom.c18
3 files changed, 24 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2602f76..e9b48cb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2011-10-23 Eric Botcazou <ebotcazou@adacore.com>
+
+ * fold-const.c (invert_tree_comparison): Always invert EQ_EXPR/NE_EXPR.
+
+ PR tree-optimization/44683
+ * tree-ssa-dom.c (record_edge_info): Record simple equivalences only if
+ we can be sure that there are no signed zeros involved.
+
2011-10-23 Jan Hubicka <jh@suse.cz>
* ipa-inline.c (estimate_badness): Scale up and handle overflows.
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index a838c34..e4c2589 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2100,15 +2100,14 @@ pedantic_non_lvalue_loc (location_t loc, tree x)
return protected_set_expr_location_unshare (x, loc);
}
-/* Given a tree comparison code, return the code that is the logical inverse
- of the given code. It is not safe to do this for floating-point
- comparisons, except for NE_EXPR and EQ_EXPR, so we receive a machine mode
- as well: if reversing the comparison is unsafe, return ERROR_MARK. */
+/* Given a tree comparison code, return the code that is the logical inverse.
+ It is generally not safe to do this for floating-point comparisons, except
+ for EQ_EXPR and NE_EXPR, so we return ERROR_MARK in this case. */
enum tree_code
invert_tree_comparison (enum tree_code code, bool honor_nans)
{
- if (honor_nans && flag_trapping_math)
+ if (honor_nans && flag_trapping_math && code != EQ_EXPR && code != NE_EXPR)
return ERROR_MARK;
switch (code)
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 8bfc91a..949acf1 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1610,12 +1610,15 @@ record_edge_info (basic_block bb)
{
tree cond = build2 (code, boolean_type_node, op0, op1);
tree inverted = invert_truthvalue_loc (loc, cond);
+ bool can_infer_simple_equiv
+ = !(HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (op0)))
+ && real_zerop (op0));
struct edge_info *edge_info;
edge_info = allocate_edge_info (true_edge);
record_conditions (edge_info, cond, inverted);
- if (code == EQ_EXPR)
+ if (can_infer_simple_equiv && code == EQ_EXPR)
{
edge_info->lhs = op1;
edge_info->rhs = op0;
@@ -1624,7 +1627,7 @@ record_edge_info (basic_block bb)
edge_info = allocate_edge_info (false_edge);
record_conditions (edge_info, inverted, cond);
- if (TREE_CODE (inverted) == EQ_EXPR)
+ if (can_infer_simple_equiv && TREE_CODE (inverted) == EQ_EXPR)
{
edge_info->lhs = op1;
edge_info->rhs = op0;
@@ -1632,17 +1635,20 @@ record_edge_info (basic_block bb)
}
else if (TREE_CODE (op0) == SSA_NAME
- && (is_gimple_min_invariant (op1)
- || TREE_CODE (op1) == SSA_NAME))
+ && (TREE_CODE (op1) == SSA_NAME
+ || is_gimple_min_invariant (op1)))
{
tree cond = build2 (code, boolean_type_node, op0, op1);
tree inverted = invert_truthvalue_loc (loc, cond);
+ bool can_infer_simple_equiv
+ = !(HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (op1)))
+ && (TREE_CODE (op1) == SSA_NAME || real_zerop (op1)));
struct edge_info *edge_info;
edge_info = allocate_edge_info (true_edge);
record_conditions (edge_info, cond, inverted);
- if (code == EQ_EXPR)
+ if (can_infer_simple_equiv && code == EQ_EXPR)
{
edge_info->lhs = op0;
edge_info->rhs = op1;
@@ -1651,7 +1657,7 @@ record_edge_info (basic_block bb)
edge_info = allocate_edge_info (false_edge);
record_conditions (edge_info, inverted, cond);
- if (TREE_CODE (inverted) == EQ_EXPR)
+ if (can_infer_simple_equiv && TREE_CODE (inverted) == EQ_EXPR)
{
edge_info->lhs = op0;
edge_info->rhs = op1;