aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@gcc.gnu.org>2004-02-28 07:33:10 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2004-02-28 07:33:10 +0000
commit68a1a5da2b17865bb90a28ba13a117092b82b608 (patch)
treeb0b51a7b4b105517f87b91d4760b368e2419d4b7 /gcc/fold-const.c
parenta10016d3b08ca2318ff1ce9e35ac5d9e0124d965 (diff)
downloadgcc-68a1a5da2b17865bb90a28ba13a117092b82b608.zip
gcc-68a1a5da2b17865bb90a28ba13a117092b82b608.tar.gz
gcc-68a1a5da2b17865bb90a28ba13a117092b82b608.tar.bz2
fold-const.c (fold): Strip NOPs that change the signedness for RSHIFT too.
* fold-const.c (fold): Strip NOPs that change the signedness for RSHIFT too. Expand comment. From-SVN: r78603
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 9178a344..04452de 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -5423,14 +5423,20 @@ fold (tree expr)
if (op == 0)
continue; /* Valid for CALL_EXPR, at least. */
- if (kind == '<' || code == RSHIFT_EXPR)
- {
- /* Signedness matters here. Perhaps we can refine this
- later. */
- STRIP_SIGN_NOPS (op);
- }
+ /* Strip any conversions that don't change the mode. This is
+ safe for every expression, except for a comparison expression
+ because its signedness is derived from its operands. So, in
+ the latter case, only strip conversions that don't change the
+ signedness.
+
+ Note that this is done as an internal manipulation within the
+ constant folder, in order to find the simplest representation
+ of the arguments so that their form can be studied. In any
+ cases, the appropriate type conversions should be put back in
+ the tree that will get out of the constant folder. */
+ if (kind == '<')
+ STRIP_SIGN_NOPS (op);
else
- /* Strip any conversions that don't change the mode. */
STRIP_NOPS (op);
if (TREE_CODE (op) == COMPLEX_CST)