On 03/04/2016 03:27 PM, Patrick Palka wrote:
I still suggest to try making write_test_expr() avoid emitting
redundant parentheses for chains of || or &&, which would fix the
original issue all the same. Previously you claimed that such a
change would not be simpler than your current patch, but I gave it a
quick try and ended up with a much smaller patch:
This looks like a reasonable stopgap if a release manager thinks this is
important enough to fix for gcc-6. Some comments below for that case.
Longer term I'm not sure - in theory maybe the switch would allow us to
generate better code, but I tried it and code size actually seems to go
up (could be jump tables however). I also noticed that in the version
with the switch we still have cases of
switch (cached_type)
{
....
default:
switch (cached_type)
{
}
}
so that might be a point where the patch could be improved to see if we
can get better code generation by collapsing these switches. Might also
be worth trying to optimize this pattern in gcc.
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)
Indentation looks wrong, but could be mailer damage. You should also
update the function comment.
+ attrs_cached
+ = write_test_expr (outf, XEXP (exp, 1), attrs_cached, flags,
+ need_parens);
Same here, watch indentation.
Bernd