From 01f834e33c2635b2e1ac7f8bb3bd0007c83a094d Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 Feb 2015 10:45:27 +0100 Subject: [PATCH] re PR tree-optimization/65014 (ice with error: type mismatch in shift expression) PR tree-optimization/65014 * fold-const.c (fold_binary_loc): When creating {L,R}ROTATE_EXPR, use original second operand of arg0 or arg1 instead of that adjusted by STRIP_NOPS. * gcc.c-torture/compile/pr65014.c: New test. From-SVN: r220640 --- gcc/ChangeLog | 7 +++++++ gcc/fold-const.c | 9 ++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr65014.c | 10 ++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr65014.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c9ac04539cc..723c62e2d15 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-02-12 Jakub Jelinek + + PR tree-optimization/65014 + * fold-const.c (fold_binary_loc): When creating {L,R}ROTATE_EXPR, + use original second operand of arg0 or arg1 instead of + that adjusted by STRIP_NOPS. + 2015-02-11 Jeff Law PR target/63347 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index b4301c78f30..83771207c49 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -10261,7 +10261,9 @@ fold_binary_loc (location_t loc, tem = build2_loc (loc, LROTATE_EXPR, TREE_TYPE (TREE_OPERAND (arg0, 0)), TREE_OPERAND (arg0, 0), - code0 == LSHIFT_EXPR ? tree01 : tree11); + code0 == LSHIFT_EXPR + ? TREE_OPERAND (arg0, 1) + : TREE_OPERAND (arg1, 1)); return fold_convert_loc (loc, type, tem); } else if (code11 == MINUS_EXPR) @@ -10283,7 +10285,8 @@ fold_binary_loc (location_t loc, ? LROTATE_EXPR : RROTATE_EXPR), TREE_TYPE (TREE_OPERAND (arg0, 0)), - TREE_OPERAND (arg0, 0), tree01)); + TREE_OPERAND (arg0, 0), + TREE_OPERAND (arg0, 1))); } else if (code01 == MINUS_EXPR) { @@ -10304,7 +10307,7 @@ fold_binary_loc (location_t loc, ? LROTATE_EXPR : RROTATE_EXPR), TREE_TYPE (TREE_OPERAND (arg0, 0)), - TREE_OPERAND (arg0, 0), tree11)); + TREE_OPERAND (arg0, 0), TREE_OPERAND (arg1, 1))); } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8d5d3f3725d..dfd7230fda4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-02-12 Jakub Jelinek + + PR tree-optimization/65014 + * gcc.c-torture/compile/pr65014.c: New test. + 2015-02-11 Jerry DeLisle PR libgfortran/57822 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr65014.c b/gcc/testsuite/gcc.c-torture/compile/pr65014.c new file mode 100644 index 00000000000..c76e95729b0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr65014.c @@ -0,0 +1,10 @@ +/* PR tree-optimization/65014 */ +/* { dg-do compile { target int32plus } } */ + +extern int x; + +unsigned +foo (unsigned int y) +{ + return (y << ((__INTPTR_TYPE__) &x)) | (y >> (32 - ((__INTPTR_TYPE__) &x))); +} -- 2.30.2