summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-reassoc.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-02-20 14:13:47 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-02-20 14:13:47 +0000
commit46ef53472228317e33520abbcd9e5e258c2053d2 (patch)
treec5e05848bec7920261ee516331b46b45437148c4 /gcc/tree-ssa-reassoc.c
parentc898f165b3aaac2e69f486ebceb086931ca0c4c1 (diff)
downloadgcc-46ef53472228317e33520abbcd9e5e258c2053d2.tar.gz
2008-02-20 Richard Guenther <rguenther@suse.de>
* tree.h (fold_real_zero_addition_p): Declare. * fold-const.c (fold_real_zero_addition_p): Export. * tree-ssa-reassoc.c (eliminate_using_constants): Also handle floating-point operations with zero and one. * gcc.dg/tree-ssa/reassoc-13.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132480 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-reassoc.c')
-rw-r--r--gcc/tree-ssa-reassoc.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index a4118c92339..6e6f5f7f442 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -39,6 +39,7 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks.h"
#include "pointer-set.h"
#include "cfgloop.h"
+#include "flags.h"
/* This is a simple global reassociation pass. It is, in part, based
on the LLVM pass of the same name (They do some things more/less
@@ -598,8 +599,10 @@ eliminate_using_constants (enum tree_code opcode,
VEC(operand_entry_t, heap) **ops)
{
operand_entry_t oelast = VEC_last (operand_entry_t, *ops);
+ tree type = TREE_TYPE (oelast->op);
- if (oelast->rank == 0 && INTEGRAL_TYPE_P (TREE_TYPE (oelast->op)))
+ if (oelast->rank == 0
+ && (INTEGRAL_TYPE_P (type) || FLOAT_TYPE_P (type)))
{
switch (opcode)
{
@@ -660,7 +663,11 @@ eliminate_using_constants (enum tree_code opcode,
}
break;
case MULT_EXPR:
- if (integer_zerop (oelast->op))
+ if (integer_zerop (oelast->op)
+ || (FLOAT_TYPE_P (type)
+ && !HONOR_NANS (TYPE_MODE (type))
+ && !HONOR_SIGNED_ZEROS (TYPE_MODE (type))
+ && real_zerop (oelast->op)))
{
if (VEC_length (operand_entry_t, *ops) != 1)
{
@@ -675,7 +682,10 @@ eliminate_using_constants (enum tree_code opcode,
return;
}
}
- else if (integer_onep (oelast->op))
+ else if (integer_onep (oelast->op)
+ || (FLOAT_TYPE_P (type)
+ && !HONOR_SNANS (TYPE_MODE (type))
+ && real_onep (oelast->op)))
{
if (VEC_length (operand_entry_t, *ops) != 1)
{
@@ -690,7 +700,11 @@ eliminate_using_constants (enum tree_code opcode,
case BIT_XOR_EXPR:
case PLUS_EXPR:
case MINUS_EXPR:
- if (integer_zerop (oelast->op))
+ if (integer_zerop (oelast->op)
+ || (FLOAT_TYPE_P (type)
+ && (opcode == PLUS_EXPR || opcode == MINUS_EXPR)
+ && fold_real_zero_addition_p (type, oelast->op,
+ opcode == MINUS_EXPR)))
{
if (VEC_length (operand_entry_t, *ops) != 1)
{