diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-14 12:42:17 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-14 12:42:17 +0000 |
commit | 1a9169ac81bf36cc33d8e0fd0c7343e228a037fa (patch) | |
tree | 89cc9ab09fa6ed3c82b52e8d764009bef28d8f1a /gcc/fold-const.c | |
parent | 2261c55964be6d7245620abda4aacddb3fe2cd6f (diff) | |
download | gcc-1a9169ac81bf36cc33d8e0fd0c7343e228a037fa.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176272 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 9640264954a..94c8926b03d 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) |