diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-27 10:32:14 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-27 10:32:14 +0000 |
commit | 76288c9ae6793fae67779f28de294d908a0fb917 (patch) | |
tree | 1c87eacf286a398e092186fd6e426d14517215cf /gcc/fold-const.c | |
parent | a12c248769d216b201337f5898ea6e12c3e58f38 (diff) | |
download | ppe42-gcc-76288c9ae6793fae67779f28de294d908a0fb917.tar.gz ppe42-gcc-76288c9ae6793fae67779f28de294d908a0fb917.zip |
2011-05-27 Richard Guenther <rguenther@suse.de>
PR middle-end/49177
* fold-const.c (fold_unary_loc): Fold (T)(A CMP B) to
A CMP B ? (T) true : (T) false for non-integral types T again.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174326 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index c9c7afa068b..ebb1d34d5f4 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7657,11 +7657,19 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0) if (TREE_TYPE (op0) == type) return op0; - /* If we have (type) (a CMP b) and type is an integral type, return - new expression involving the new type. */ - if (COMPARISON_CLASS_P (op0) && INTEGRAL_TYPE_P (type)) - return fold_build2_loc (loc, TREE_CODE (op0), type, TREE_OPERAND (op0, 0), - TREE_OPERAND (op0, 1)); + if (COMPARISON_CLASS_P (op0)) + { + /* If we have (type) (a CMP b) and type is an integral type, return + new expression involving the new type. */ + if (INTEGRAL_TYPE_P (type)) + return fold_build2_loc (loc, TREE_CODE (op0), type, + TREE_OPERAND (op0, 0), + TREE_OPERAND (op0, 1)); + else + return fold_build3_loc (loc, COND_EXPR, type, op0, + fold_convert (type, boolean_true_node), + fold_convert (type, boolean_false_node)); + } /* Handle cases of two conversions in a row. */ if (CONVERT_EXPR_P (op0)) |