diff options
author | Roger Sayle <roger@eyesopen.com> | 2005-03-13 22:34:03 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2005-03-13 22:34:03 +0000 |
commit | 362cb1bb1f100075cb261248d64c7ba0cb748cec (patch) | |
tree | b32aa07e2c73110ffba0edde92f3970f84f19c46 /gcc | |
parent | 334f3a34cd96d89092c7551dc221ca1150fa4e07 (diff) | |
download | gcc-362cb1bb1f100075cb261248d64c7ba0cb748cec.zip gcc-362cb1bb1f100075cb261248d64c7ba0cb748cec.tar.gz gcc-362cb1bb1f100075cb261248d64c7ba0cb748cec.tar.bz2 |
re PR middle-end/19331 (Inefficient code generated for bitfield assignment)
PR middle-end/19331
* tree.c (get_unwidened): Treat CONVERT_EXPR and NOP_EXPR identically.
* fold-const.c (fold_sign_changed_comparison): Likewise.
(fold_binary): Optimize comparisons against widened operands if
the extension is represented by a CONVERT_EXPR, same as a NOP_EXPR.
From-SVN: r96397
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/fold-const.c | 11 | ||||
-rw-r--r-- | gcc/tree.c | 7 |
3 files changed, 20 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2a4a78e..78f5ba5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2005-03-13 Roger Sayle <roger@eyesopen.com> + + PR middle-end/19331 + * tree.c (get_unwidened): Treat CONVERT_EXPR and NOP_EXPR identically. + * fold-const.c (fold_sign_changed_comparison): Likewise. + (fold_binary): Optimize comparisons against widened operands if + the extension is represented by a CONVERT_EXPR, same as a NOP_EXPR. + 2005-03-14 Eric Botcazou <ebotcazou@libertysurf.fr> * config/sparc/sparc.c (struct_value_alias_set): New global variable. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 3fdfb92..6a00abe 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -6148,7 +6148,8 @@ fold_sign_changed_comparison (enum tree_code code, tree type, tree arg0_inner, tmp; tree inner_type, outer_type; - if (TREE_CODE (arg0) != NOP_EXPR) + if (TREE_CODE (arg0) != NOP_EXPR + && TREE_CODE (arg0) != CONVERT_EXPR) return NULL_TREE; outer_type = TREE_TYPE (arg0); @@ -6159,7 +6160,8 @@ fold_sign_changed_comparison (enum tree_code code, tree type, return NULL_TREE; if (TREE_CODE (arg1) != INTEGER_CST - && !(TREE_CODE (arg1) == NOP_EXPR + && !((TREE_CODE (arg1) == NOP_EXPR + || TREE_CODE (arg1) == CONVERT_EXPR) && TREE_TYPE (TREE_OPERAND (arg1, 0)) == inner_type)) return NULL_TREE; @@ -6180,7 +6182,7 @@ fold_sign_changed_comparison (enum tree_code code, tree type, else arg1 = fold_convert (inner_type, arg1); - return fold (build (code, type, arg0_inner, arg1)); + return fold (build2 (code, type, arg0_inner, arg1)); } /* Tries to replace &a[idx] CODE s * delta with &a[idx CODE delta], if s is @@ -9150,7 +9152,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) TREE_OPERAND (arg0, 0), TREE_OPERAND (arg0, 1))); else if (TREE_CODE (TREE_TYPE (arg0)) == INTEGER_TYPE - && TREE_CODE (arg0) == NOP_EXPR) + && (TREE_CODE (arg0) == NOP_EXPR + || TREE_CODE (arg0) == CONVERT_EXPR)) { /* If we are widening one operand of an integer comparison, see if the other operand is similarly being widened. Perhaps we @@ -4729,7 +4729,8 @@ get_unwidened (tree op, tree for_type) && TYPE_UNSIGNED (type)); tree win = op; - while (TREE_CODE (op) == NOP_EXPR) + while (TREE_CODE (op) == NOP_EXPR + || TREE_CODE (op) == CONVERT_EXPR) { int bitschange = TYPE_PRECISION (TREE_TYPE (op)) @@ -4759,7 +4760,9 @@ get_unwidened (tree op, tree for_type) /* TYPE_UNSIGNED says whether this is a zero-extension. Let's avoid computing it if it does not affect WIN and if UNS will not be needed again. */ - if ((uns || TREE_CODE (op) == NOP_EXPR) + if ((uns + || TREE_CODE (op) == NOP_EXPR + || TREE_CODE (op) == CONVERT_EXPR) && TYPE_UNSIGNED (TREE_TYPE (op))) { uns = 1; |