diff options
author | Richard Guenther <rguenther@suse.de> | 2011-07-14 12:42:17 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2011-07-14 12:42:17 +0000 |
commit | fbf3fee2b959926c4df4295eba74ea144f0c6a00 (patch) | |
tree | 89cc9ab09fa6ed3c82b52e8d764009bef28d8f1a | |
parent | b953c2b834c1f92f20729a51b4cd4d15b2426d7a (diff) | |
download | gcc-fbf3fee2b959926c4df4295eba74ea144f0c6a00.zip gcc-fbf3fee2b959926c4df4295eba74ea144f0c6a00.tar.gz gcc-fbf3fee2b959926c4df4295eba74ea144f0c6a00.tar.bz2 |
fold-const.c (fold_binary_loc): Convert the !bool_var result...
2011-07-14 Richard Guenther <rguenther@suse.de>
* fold-const.c (fold_binary_loc): Convert the !bool_var result,
not bool_var when folding bool_var != 1 or bool_var == 0.
From-SVN: r176272
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fold-const.c | 10 |
2 files changed, 11 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2341964..61b4535 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-07-14 Richard Guenther <rguenther@suse.de> + + * fold-const.c (fold_binary_loc): Convert the !bool_var result, + not bool_var when folding bool_var != 1 or bool_var == 0. + 2011-07-14 Bernd Schmidt <bernds@codesourcery.com> * haifa-sched.c (schedule_insns): Remove outdated comment. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 9640264..94c8926 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -12156,14 +12156,16 @@ fold_binary_loc (location_t loc, /* bool_var != 1 becomes !bool_var. */ if (TREE_CODE (TREE_TYPE (arg0)) == BOOLEAN_TYPE && integer_onep (arg1) && code == NE_EXPR) - return fold_build1_loc (loc, TRUTH_NOT_EXPR, type, - fold_convert_loc (loc, type, arg0)); + return fold_convert_loc (loc, type, + fold_build1_loc (loc, TRUTH_NOT_EXPR, + TREE_TYPE (arg0), arg0)); /* bool_var == 0 becomes !bool_var. */ if (TREE_CODE (TREE_TYPE (arg0)) == BOOLEAN_TYPE && integer_zerop (arg1) && code == EQ_EXPR) - return fold_build1_loc (loc, TRUTH_NOT_EXPR, type, - fold_convert_loc (loc, type, arg0)); + return fold_convert_loc (loc, type, + fold_build1_loc (loc, TRUTH_NOT_EXPR, + TREE_TYPE (arg0), arg0)); /* !exp != 0 becomes !exp */ if (TREE_CODE (arg0) == TRUTH_NOT_EXPR && integer_zerop (arg1) |