* [patch] PR tree-optimization/55350: invalid pointer operand to PLUS_EXPR
@ 2012-11-20 17:46 Aldy Hernandez
2012-11-20 17:52 ` Jakub Jelinek
2012-11-20 22:25 ` Eric Botcazou
0 siblings, 2 replies; 5+ messages in thread
From: Aldy Hernandez @ 2012-11-20 17:46 UTC (permalink / raw)
To: gcc-patches; +Cc: wschmidt
[-- Attachment #1: Type: text/plain, Size: 281 bytes --]
The problem here is that the SLSR pass is promoting a POINTER_PLUS_EXPR
to a PLUS_EXPR. Since pointer arithmetic is invalid in
{PLUS,MINUS}_EXPR's, the gimple verifier chokes on the invalid statement.
Fixed by maintaining the POINTER_PLUS_EXPR when appropriate.
OK for trunk?
[-- Attachment #2: curr --]
[-- Type: text/plain, Size: 1497 bytes --]
commit ae7b615a11be6a0c5cc00f7ea0bf29c142931490
Author: Aldy Hernandez <aldyh@redhat.com>
Date: Tue Nov 20 11:20:58 2012 -0600
PR tree-optimization/55350
* gimple-ssa-strength-reduction.c (replace_dependent): Handle
POINTER_{PLUS,MINUS}_EXPR correctly.
diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index 8e2a247..65fc6b1 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -1643,10 +1643,19 @@ replace_dependent (slsr_cand_t c, enum tree_code cand_code)
basis = lookup_cand (c->basis);
basis_name = gimple_assign_lhs (basis->cand_stmt);
- incr_type = TREE_TYPE (gimple_assign_rhs1 (c->cand_stmt));
- code = PLUS_EXPR;
+ if (cand_code == POINTER_PLUS_EXPR)
+ {
+ incr_type = sizetype;
+ code = cand_code;
+ }
+ else
+ {
+ incr_type = TREE_TYPE (gimple_assign_rhs1 (c->cand_stmt));
+ code = PLUS_EXPR;
+ }
- if (bump.is_negative ())
+ if (bump.is_negative ()
+ && cand_code != POINTER_PLUS_EXPR)
{
code = MINUS_EXPR;
bump = -bump;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr55350.c b/gcc/testsuite/gcc.c-torture/compile/pr55350.c
new file mode 100644
index 0000000..f10daea
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr55350.c
@@ -0,0 +1,8 @@
+void
+foo (__INTPTR_TYPE__ x, __INTPTR_TYPE__ y)
+{
+ int i;
+ void **a = (void *) (8UL * (x / 8UL));
+ for (i = 0; i < x; i++)
+ a[i] = (void *) y;
+}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] PR tree-optimization/55350: invalid pointer operand to PLUS_EXPR
2012-11-20 17:46 [patch] PR tree-optimization/55350: invalid pointer operand to PLUS_EXPR Aldy Hernandez
@ 2012-11-20 17:52 ` Jakub Jelinek
2012-11-20 22:25 ` Eric Botcazou
1 sibling, 0 replies; 5+ messages in thread
From: Jakub Jelinek @ 2012-11-20 17:52 UTC (permalink / raw)
To: Aldy Hernandez; +Cc: gcc-patches, wschmidt
On Tue, Nov 20, 2012 at 11:46:06AM -0600, Aldy Hernandez wrote:
> The problem here is that the SLSR pass is promoting a
> POINTER_PLUS_EXPR to a PLUS_EXPR. Since pointer arithmetic is
> invalid in {PLUS,MINUS}_EXPR's, the gimple verifier chokes on the
> invalid statement.
>
> Fixed by maintaining the POINTER_PLUS_EXPR when appropriate.
>
> OK for trunk?
Ok, thanks.
> - if (bump.is_negative ())
> + if (bump.is_negative ()
> + && cand_code != POINTER_PLUS_EXPR)
> {
> code = MINUS_EXPR;
> bump = -bump;
I wonder if this isn't unsafe even when bump is the shwi minimum
(say LONG_MIN for LP64 target/64-bit HWI). But sure, it is preexisting
code, so perhaps something for Bill to look at later.
Jakub
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] PR tree-optimization/55350: invalid pointer operand to PLUS_EXPR
2012-11-20 17:46 [patch] PR tree-optimization/55350: invalid pointer operand to PLUS_EXPR Aldy Hernandez
2012-11-20 17:52 ` Jakub Jelinek
@ 2012-11-20 22:25 ` Eric Botcazou
2012-11-20 22:34 ` Aldy Hernandez
1 sibling, 1 reply; 5+ messages in thread
From: Eric Botcazou @ 2012-11-20 22:25 UTC (permalink / raw)
To: Aldy Hernandez; +Cc: gcc-patches, wschmidt
> The problem here is that the SLSR pass is promoting a POINTER_PLUS_EXPR
> to a PLUS_EXPR. Since pointer arithmetic is invalid in
> {PLUS,MINUS}_EXPR's, the gimple verifier chokes on the invalid statement.
>
> Fixed by maintaining the POINTER_PLUS_EXPR when appropriate.
>
> OK for trunk?
The ChangeLog mentions POINTER_MINUS_EXPR, which doesn't exist.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] PR tree-optimization/55350: invalid pointer operand to PLUS_EXPR
2012-11-20 22:25 ` Eric Botcazou
@ 2012-11-20 22:34 ` Aldy Hernandez
2012-11-20 23:01 ` Eric Botcazou
0 siblings, 1 reply; 5+ messages in thread
From: Aldy Hernandez @ 2012-11-20 22:34 UTC (permalink / raw)
To: Eric Botcazou; +Cc: gcc-patches, wschmidt
On 11/20/12 16:23, Eric Botcazou wrote:
>> The problem here is that the SLSR pass is promoting a POINTER_PLUS_EXPR
>> to a PLUS_EXPR. Since pointer arithmetic is invalid in
>> {PLUS,MINUS}_EXPR's, the gimple verifier chokes on the invalid statement.
>>
>> Fixed by maintaining the POINTER_PLUS_EXPR when appropriate.
>>
>> OK for trunk?
>
> The ChangeLog mentions POINTER_MINUS_EXPR, which doesn't exist.
>
Actually the ChangeLog is correct, what was incorrect was the svn commit
message. Is there a way to change the commit message retroactively?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] PR tree-optimization/55350: invalid pointer operand to PLUS_EXPR
2012-11-20 22:34 ` Aldy Hernandez
@ 2012-11-20 23:01 ` Eric Botcazou
0 siblings, 0 replies; 5+ messages in thread
From: Eric Botcazou @ 2012-11-20 23:01 UTC (permalink / raw)
To: Aldy Hernandez; +Cc: gcc-patches, wschmidt
> Actually the ChangeLog is correct, what was incorrect was the svn commit
> message. Is there a way to change the commit message retroactively?
Probably, but I wouldn't bother about that.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-11-20 23:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-20 17:46 [patch] PR tree-optimization/55350: invalid pointer operand to PLUS_EXPR Aldy Hernandez
2012-11-20 17:52 ` Jakub Jelinek
2012-11-20 22:25 ` Eric Botcazou
2012-11-20 22:34 ` Aldy Hernandez
2012-11-20 23:01 ` Eric Botcazou
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).