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/fold-const.c | |
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/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 11 |
1 files changed, 7 insertions, 4 deletions
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 |