diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-06-30 08:52:43 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-06-30 08:52:43 +0000 |
commit | 4c4e99c34aae02d1215410f2b59c5c5edce641eb (patch) | |
tree | b9c50c2ea116fc10568c7c63dc4c245ba9e28da1 /gcc/fold-const.c | |
parent | 4e1b04b0cc2248df1b7820c04743935147bd138e (diff) | |
download | gcc-4c4e99c34aae02d1215410f2b59c5c5edce641eb.tar.gz |
PR middle-end/71693
* fold-const.c (fold_binary_loc) <case RROTATE_EXPR>: Cast
TREE_OPERAND (arg0, 0) and TREE_OPERAND (arg0, 1) to type
first when permuting bitwise operation with rotate. Cast
TREE_OPERAND (arg0, 0) to type when cancelling two rotations.
* gcc.c-torture/compile/pr71693.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237875 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 3b9500dafe6..f97b8bf6978 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -10294,11 +10294,15 @@ fold_binary_loc (location_t loc, || TREE_CODE (arg0) == BIT_IOR_EXPR || TREE_CODE (arg0) == BIT_XOR_EXPR) && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) - return fold_build2_loc (loc, TREE_CODE (arg0), type, - fold_build2_loc (loc, code, type, - TREE_OPERAND (arg0, 0), arg1), - fold_build2_loc (loc, code, type, - TREE_OPERAND (arg0, 1), arg1)); + { + tree arg00 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); + tree arg01 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 1)); + return fold_build2_loc (loc, TREE_CODE (arg0), type, + fold_build2_loc (loc, code, type, + arg00, arg1), + fold_build2_loc (loc, code, type, + arg01, arg1)); + } /* Two consecutive rotates adding up to the some integer multiple of the precision of the type can be ignored. */ @@ -10307,7 +10311,7 @@ fold_binary_loc (location_t loc, && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST && wi::umod_trunc (wi::add (arg1, TREE_OPERAND (arg0, 1)), prec) == 0) - return TREE_OPERAND (arg0, 0); + return fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); return NULL_TREE; |