Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/gpl3/gcc/dist/gcc Apply upstream commit:
details: https://anonhg.NetBSD.org/src/rev/0ce62d712ea1
branches: trunk
changeset: 361203:0ce62d712ea1
user: maya <maya%NetBSD.org@localhost>
date: Tue Apr 17 10:02:49 2018 +0000
description:
Apply upstream commit:
From: ppalka <ppalka@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 27 Apr 2016 21:18:05 +0000
Subject: [PATCH] Reduce nesting of parentheses in conditionals generated by
genattrtab
gcc/ChangeLog:
* genattrtab.c (write_test_expr): New parameter EMIT_PARENS
which defaults to true. Emit an outer pair of parentheses only if
EMIT_PARENS. When continuing a chain of && or || (or & or |),
don't emit parentheses for the right-hand operand.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235536
gcc/arm generates so many parens it hits a bracket depth limited which is
enforced by clang. This reduces the number of parens generated and avoids the
need to increase bracket depth.
Fixes PR toolchain/53178 properly.
diffstat:
external/gpl3/gcc/dist/gcc/genattrtab.c | 33 ++++++++++++++++++++++++---------
1 files changed, 24 insertions(+), 9 deletions(-)
diffs (69 lines):
diff -r cc665d092d77 -r 0ce62d712ea1 external/gpl3/gcc/dist/gcc/genattrtab.c
--- a/external/gpl3/gcc/dist/gcc/genattrtab.c Tue Apr 17 09:06:33 2018 +0000
+++ b/external/gpl3/gcc/dist/gcc/genattrtab.c Tue Apr 17 10:02:49 2018 +0000
@@ -3416,7 +3416,10 @@
/* Given a piece of RTX, print a C expression to test its truth value to OUTF.
We use AND and IOR both for logical and bit-wise operations, so
- interpret them as logical unless they are inside a comparison expression. */
+ interpret them as logical unless they are inside a comparison expression.
+
+ An outermost pair of parentheses is emitted around this C expression unless
+ EMIT_PARENS is false. */
/* Interpret AND/IOR as bit-wise operations instead of logical. */
#define FLG_BITWISE 1
@@ -3432,16 +3435,16 @@
#define FLG_OUTSIDE_AND 8
static unsigned int
-write_test_expr (FILE *outf, rtx exp, unsigned int attrs_cached, int flags)
+write_test_expr (FILE *outf, rtx exp, unsigned int attrs_cached, int flags,
+ bool emit_parens = true)
{
int comparison_operator = 0;
RTX_CODE code;
struct attr_desc *attr;
- /* In order not to worry about operator precedence, surround our part of
- the expression with parentheses. */
-
- fprintf (outf, "(");
+ if (emit_parens)
+ fprintf (outf, "(");
+
code = GET_CODE (exp);
switch (code)
{
@@ -3575,8 +3578,18 @@
|| GET_CODE (XEXP (exp, 1)) == EQ_ATTR
|| (GET_CODE (XEXP (exp, 1)) == NOT
&& GET_CODE (XEXP (XEXP (exp, 1), 0)) == EQ_ATTR)))
- attrs_cached
- = write_test_expr (outf, XEXP (exp, 1), attrs_cached, flags);
+ {
+ bool need_parens = true;
+
+ /* No need to emit parentheses around the right-hand operand if we are
+ continuing a chain of && or || (or & or |). */
+ if (GET_CODE (XEXP (exp, 1)) == code)
+ need_parens = false;
+
+ attrs_cached
+ = write_test_expr (outf, XEXP (exp, 1), attrs_cached, flags,
+ need_parens);
+ }
else
write_test_expr (outf, XEXP (exp, 1), attrs_cached,
flags | comparison_operator);
@@ -3794,7 +3807,9 @@
GET_RTX_NAME (code));
}
- fprintf (outf, ")");
+ if (emit_parens)
+ fprintf (outf, ")");
+
return attrs_cached;
}
Home |
Main Index |
Thread Index |
Old Index