aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2003-10-29 18:26:29 -0800
committerRichard Henderson <rth@gcc.gnu.org>2003-10-29 18:26:29 -0800
commite7824b3ed5324c1c7dc8b159ea05bcdebf655345 (patch)
treec8eaac33f8d526dce7ee1fcd726ce4fc064b17eb /gcc/fold-const.c
parentc35d187fc31fdd5836d1acb13e29a03537d22b46 (diff)
downloadgcc-e7824b3ed5324c1c7dc8b159ea05bcdebf655345.zip
gcc-e7824b3ed5324c1c7dc8b159ea05bcdebf655345.tar.gz
gcc-e7824b3ed5324c1c7dc8b159ea05bcdebf655345.tar.bz2
fold-const.c (fold_single_bit_test): Convert the input to the operational intermediate type.
* fold-const.c (fold_single_bit_test): Convert the input to the operational intermediate type. From-SVN: r73077
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index f248cd6..85909a3 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -5036,7 +5036,7 @@ fold_single_bit_test (enum tree_code code, tree arg0, tree arg1,
int bitnum = tree_log2 (TREE_OPERAND (arg0, 1));
enum machine_mode operand_mode = TYPE_MODE (type);
int ops_unsigned;
- tree signed_type, unsigned_type;
+ tree signed_type, unsigned_type, intermediate_type;
tree arg00;
/* If we have (A & C) != 0 where C is the sign bit of A, convert
@@ -5082,22 +5082,23 @@ fold_single_bit_test (enum tree_code code, tree arg0, tree arg1,
signed_type = (*lang_hooks.types.type_for_mode) (operand_mode, 0);
unsigned_type = (*lang_hooks.types.type_for_mode) (operand_mode, 1);
+ intermediate_type = ops_unsigned ? unsigned_type : signed_type;
+ inner = convert (intermediate_type, inner);
if (bitnum != 0)
- inner = build (RSHIFT_EXPR, ops_unsigned ? unsigned_type : signed_type,
+ inner = build (RSHIFT_EXPR, intermediate_type,
inner, size_int (bitnum));
if (code == EQ_EXPR)
- inner = build (BIT_XOR_EXPR, ops_unsigned ? unsigned_type : signed_type,
+ inner = build (BIT_XOR_EXPR, intermediate_type,
inner, integer_one_node);
/* Put the AND last so it can combine with more things. */
- inner = build (BIT_AND_EXPR, ops_unsigned ? unsigned_type : signed_type,
+ inner = build (BIT_AND_EXPR, intermediate_type,
inner, integer_one_node);
/* Make sure to return the proper type. */
- if (TREE_TYPE (inner) != result_type)
- inner = convert (result_type, inner);
+ inner = convert (result_type, inner);
return inner;
}