aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2004-06-17 20:19:57 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2004-06-17 20:19:57 +0000
commit1382f0f09da0d329609d3fccd6a4eafa48e94665 (patch)
treebc170af4d8366927c41e6b65b1e754e6f985e975
parent801e227002b90184b6880619b00eec78007f4a30 (diff)
downloadgcc-1382f0f09da0d329609d3fccd6a4eafa48e94665.zip
gcc-1382f0f09da0d329609d3fccd6a4eafa48e94665.tar.gz
gcc-1382f0f09da0d329609d3fccd6a4eafa48e94665.tar.bz2
* fold-const.c (fold_relational_const): Use constant_boolean_node.
From-SVN: r83307
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/fold-const.c42
2 files changed, 21 insertions, 25 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5e6e925..946ef76 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2004-06-17 Roger Sayle <roger@eyesopen.com>
+
+ * fold-const.c (fold_relational_const): Use constant_boolean_node.
+
2004-06-17 Jan Hubicka <jh@suse.cz>
PR target/15433
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 91f4054..3494d4a 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -9966,8 +9966,7 @@ fold_not_const (tree arg0, tree type)
static tree
fold_relational_const (enum tree_code code, tree type, tree op0, tree op1)
{
- tree tem;
- int invert;
+ int result, invert;
/* From here on, the only cases we handle are when the result is
known to be a constant.
@@ -9981,14 +9980,15 @@ fold_relational_const (enum tree_code code, tree type, tree op0, tree op1)
if (code == LE_EXPR || code == GT_EXPR)
{
- tem = op0, op0 = op1, op1 = tem;
+ tree tem = op0;
+ op0 = op1;
+ op1 = tem;
code = swap_tree_comparison (code);
}
/* Note that it is safe to invert for real values here because we
will check below in the one case that it matters. */
- tem = NULL_TREE;
invert = 0;
if (code == NE_EXPR || code == GE_EXPR)
{
@@ -10001,17 +10001,16 @@ fold_relational_const (enum tree_code code, tree type, tree op0, tree op1)
if (TREE_CODE (op0) == INTEGER_CST && TREE_CODE (op1) == INTEGER_CST)
{
if (code == EQ_EXPR)
- tem = build_int_2 (tree_int_cst_equal (op0, op1), 0);
+ result = tree_int_cst_equal (op0, op1);
+ else if (TYPE_UNSIGNED (TREE_TYPE (op0)))
+ result = INT_CST_LT_UNSIGNED (op0, op1);
else
- tem = build_int_2 ((TYPE_UNSIGNED (TREE_TYPE (op0))
- ? INT_CST_LT_UNSIGNED (op0, op1)
- : INT_CST_LT (op0, op1)),
- 0);
+ result = INT_CST_LT (op0, op1);
}
else if (code == EQ_EXPR && !TREE_SIDE_EFFECTS (op0)
&& integer_zerop (op1) && tree_expr_nonzero_p (op0))
- tem = build_int_2 (0, 0);
+ result = 0;
/* Two real constants can be compared explicitly. */
else if (TREE_CODE (op0) == REAL_CST && TREE_CODE (op1) == REAL_CST)
@@ -10025,28 +10024,21 @@ fold_relational_const (enum tree_code code, tree type, tree op0, tree op1)
if (REAL_VALUE_ISNAN (TREE_REAL_CST (op0))
|| REAL_VALUE_ISNAN (TREE_REAL_CST (op1)))
- tem = build_int_2 (invert && code == LT_EXPR, 0);
+ result = invert && code == LT_EXPR;
else if (code == EQ_EXPR)
- tem = build_int_2 (REAL_VALUES_EQUAL (TREE_REAL_CST (op0),
- TREE_REAL_CST (op1)),
- 0);
+ result = REAL_VALUES_EQUAL (TREE_REAL_CST (op0),
+ TREE_REAL_CST (op1));
else
- tem = build_int_2 (REAL_VALUES_LESS (TREE_REAL_CST (op0),
- TREE_REAL_CST (op1)),
- 0);
+ result = REAL_VALUES_LESS (TREE_REAL_CST (op0),
+ TREE_REAL_CST (op1));
}
-
- if (tem == NULL_TREE)
+ else
return NULL_TREE;
if (invert)
- TREE_INT_CST_LOW (tem) ^= 1;
-
- TREE_TYPE (tem) = type;
- if (TREE_CODE (type) == BOOLEAN_TYPE)
- return lang_hooks.truthvalue_conversion (tem);
- return tem;
+ result ^= 1;
+ return constant_boolean_node (result, type);
}
/* Build an expression for the address of T. Folds away INDIRECT_REF to