* [PATCH] Fix condition in is_aligning_offset (PR c/61271)
@ 2014-08-21 15:52 Marek Polacek
2014-08-26 8:04 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Marek Polacek @ 2014-08-21 15:52 UTC (permalink / raw)
To: GCC Patches
This is one of the issues that -Wlogical-not-parentheses detected.
Interestingly, this code has been added in 2002 (!). I believe the
logical not there should be just removed; the comment above it says
/* We must now have a BIT_AND_EXPR with a constant that is one less than
power of 2 and which is larger than BIGGEST_ALIGNMENT. */
so if the constant is not one less than power of 2 (exact_log2 returns -1),
we should bail out.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
Should I backport this to 4.9/4.8 after a while?
2014-08-21 Marek Polacek <polacek@redhat.com>
PR c/61271
* expr.c (is_aligning_offset): Remove logical not.
diff --git gcc/expr.c gcc/expr.c
index 920d47b..05d81dc 100644
--- gcc/expr.c
+++ gcc/expr.c
@@ -10721,7 +10721,7 @@ is_aligning_offset (const_tree offset, const_tree exp)
|| !tree_fits_uhwi_p (TREE_OPERAND (offset, 1))
|| compare_tree_int (TREE_OPERAND (offset, 1),
BIGGEST_ALIGNMENT / BITS_PER_UNIT) <= 0
- || !exact_log2 (tree_to_uhwi (TREE_OPERAND (offset, 1)) + 1) < 0)
+ || exact_log2 (tree_to_uhwi (TREE_OPERAND (offset, 1)) + 1) < 0)
return 0;
/* Look at the first operand of BIT_AND_EXPR and strip any conversion.
Marek
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix condition in is_aligning_offset (PR c/61271)
2014-08-21 15:52 [PATCH] Fix condition in is_aligning_offset (PR c/61271) Marek Polacek
@ 2014-08-26 8:04 ` Richard Biener
2014-09-01 14:20 ` Marek Polacek
0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2014-08-26 8:04 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches
On Thu, Aug 21, 2014 at 5:52 PM, Marek Polacek <polacek@redhat.com> wrote:
> This is one of the issues that -Wlogical-not-parentheses detected.
> Interestingly, this code has been added in 2002 (!). I believe the
> logical not there should be just removed; the comment above it says
> /* We must now have a BIT_AND_EXPR with a constant that is one less than
> power of 2 and which is larger than BIGGEST_ALIGNMENT. */
> so if the constant is not one less than power of 2 (exact_log2 returns -1),
> we should bail out.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
Ok.
> Should I backport this to 4.9/4.8 after a while?
Yes please.
Thanks,
Richard.
> 2014-08-21 Marek Polacek <polacek@redhat.com>
>
> PR c/61271
> * expr.c (is_aligning_offset): Remove logical not.
>
> diff --git gcc/expr.c gcc/expr.c
> index 920d47b..05d81dc 100644
> --- gcc/expr.c
> +++ gcc/expr.c
> @@ -10721,7 +10721,7 @@ is_aligning_offset (const_tree offset, const_tree exp)
> || !tree_fits_uhwi_p (TREE_OPERAND (offset, 1))
> || compare_tree_int (TREE_OPERAND (offset, 1),
> BIGGEST_ALIGNMENT / BITS_PER_UNIT) <= 0
> - || !exact_log2 (tree_to_uhwi (TREE_OPERAND (offset, 1)) + 1) < 0)
> + || exact_log2 (tree_to_uhwi (TREE_OPERAND (offset, 1)) + 1) < 0)
> return 0;
>
> /* Look at the first operand of BIT_AND_EXPR and strip any conversion.
>
> Marek
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix condition in is_aligning_offset (PR c/61271)
2014-08-26 8:04 ` Richard Biener
@ 2014-09-01 14:20 ` Marek Polacek
0 siblings, 0 replies; 3+ messages in thread
From: Marek Polacek @ 2014-09-01 14:20 UTC (permalink / raw)
To: Richard Biener; +Cc: GCC Patches
On Tue, Aug 26, 2014 at 10:04:36AM +0200, Richard Biener wrote:
> > Should I backport this to 4.9/4.8 after a while?
>
> Yes please.
Done.
Marek
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-01 14:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-21 15:52 [PATCH] Fix condition in is_aligning_offset (PR c/61271) Marek Polacek
2014-08-26 8:04 ` Richard Biener
2014-09-01 14:20 ` Marek Polacek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).