Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Kenner
> I'm wondering why verify_ssa doesn't detect this. It does. See for instance pr 15740, which had generated an ICE. But what I don't understand is why it didn't ICE in my case. That we don't constantly see problems is indicitive that the front-ends are good about using mark_

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Henderson
On Tue, Sep 06, 2005 at 03:37:26PM -0400, Richard Kenner wrote: > I'm wondering why verify_ssa doesn't detect this. It does. See for instance pr 15740, which had generated an ICE. That we don't constantly see problems is indicitive that the front-ends are good about using mark_addressable when

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Kenner
> Yeah, that's what I realized in working on this problem. Is it worth > adding a flag to show that this is a gimple-generated variable so we > can have an assert that we're not trying to mark it as addressable? What has gimple-generated got to do with it? Well, if it's gimple-ge

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Henderson
On Tue, Sep 06, 2005 at 03:07:35PM -0400, Richard Kenner wrote: > Yeah, that's what I realized in working on this problem. Is it worth adding > a flag to show that this is a gimple-generated variable so we can have > an assert that we're not trying to mark it as addressable? What has gimple-gener

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Kenner
If part way through gimplification you mark a variable as addressable, then you invalidate the gimplification of preceeding statements. At least for variables whose type satisfies is_gimple_reg_type. Yeah, that's what I realized in working on this problem. Is it worth adding a fla

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Henderson
On Tue, Sep 06, 2005 at 02:41:14PM -0400, Richard Kenner wrote: > It certainly calls mark_addressable in various places, so I don't follow. Then these are bugs waiting to happen. If part way through gimplification you mark a variable as addressable, then you invalidate the gimplification of prece

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Kenner
The gimplifier never sets TREE_ADDRESSABLE on existing variables. It certainly calls mark_addressable in various places, so I don't follow.

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Henderson
On Tue, Sep 06, 2005 at 01:45:22PM -0400, Richard Kenner wrote: > Thanks. I was just copying that code without full understanding > of what it was doing. But where is that flag cleared when TREE_ADDRESSABLE > is set? I can't find anything that ever clears it? Because TREE_ADDRESSABLE should alr

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Kenner
>if (TREE_CODE (TREE_TYPE (op)) == COMPLEX_TYPE) > DECL_COMPLEX_GIMPLE_REG_P (new_var) = 1; You should not have set this; you're taking the address of the variable after all. Thanks. I was just copying that code without full understanding of what it was doing. But w

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Henderson
On Tue, Sep 06, 2005 at 08:04:29AM -0400, Richard Kenner wrote: > if (TREE_CODE (TREE_TYPE (op)) == COMPLEX_TYPE) > DECL_COMPLEX_GIMPLE_REG_P (new_var) = 1; You should not have set this; you're taking the address of the variable after all. > I don't care for the duplication of c

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Paul Brook
>     But only where the semantics are well defined. I can think of several >     different possible semantics for talking the address of arbitrary >     things. > > The counter-argument is that it can used when the semantics need *not* be > well-defined, in other words, where you're saying you do

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Gabriel Dos Reis
[EMAIL PROTECTED] (Richard Kenner) writes: | The whole point of the gimplifier is to avoid making too many restrictions on | what are valid trees: it's GIMPLE where we want to make those restrictions. | It seems very duplicative to me to say that the process of creating | temporaries for certain e

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Kenner
But only where the semantics are well defined. I can think of several different possible semantics for talking the address of arbitrary things. The counter-argument is that it can used when the semantics need *not* be well-defined, in other words, where you're saying you don't care.

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Paul Brook
> But secondly, why make that restriction at all? Suppose I have a function > to which a language semantics requires passing by reference. Now suppose > the operand is "a + b". Why not just make an ADDR_EXPR of the PLUS_EXPR? > > Sure, the front end *could* make a temporary, but the gimplifier h

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Kenner
Hmm, odd that such a rule wouldn't exist. Not at all odd! We have almost no rules *whatsoever* on what's allowed in each operand of a GENERIC tree. That's the problem here. To me it seems an ADDR_EXPR only makes sense on something that is addressable, First of all, define "addres

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Steven Bosscher
On Tuesday 06 September 2005 15:37, Richard Kenner wrote: > What would be your proposal as to which nodes it's valid to have as > operands of an ADDR_EXPR? We certainly never even thought of such a rule > before. Hmm, odd that such a rule wouldn't exist. To me it seems an ADDR_EXPR only makes se

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Kenner
Can't you use get_initialized_tmp_var, then? No, and that's the whole point! You need to set TREE_ADDRESSABLE on the variable *before* gimplifying the MODIFY_EXPR.

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Gabriel Dos Reis
Steven Bosscher <[EMAIL PROTECTED]> writes: | On Tuesday 06 September 2005 15:05, Gabriel Dos Reis wrote: | > Richard Guenther <[EMAIL PROTECTED]> writes: | > | On 9/6/05, Richard Kenner <[EMAIL PROTECTED]> wrote: | > | > I don't think we ever defined "valid GENERIC" that way. | > | > | > | >

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Giovanni Bajo
Richard Kenner <[EMAIL PROTECTED]> wrote: > /* Otherwise, if we are taking the address of something that is > neither a refence, declaration, or constant, make a variable for the operand > here and then take its address. If we don't do it this way, we may > confuse the gimplifier because it

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Kenner
Because it doesn't make sense to take the address of a COMPOUND_EXPR for example? As Kenner puts it himself: "This turned out to be the "well known" problem that the Ada front end is making an ADDR_EXPR of odd things, in this case a COMPOUND_EXPR." So there

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Kenner
The only useful definition is that valid GENERIC is what the gimplifier can turn into valid GIMPLE, which is much more well-defined ;) Modulo bugs in the gimplifier of course ... But that's the whole problem! If you have a tree that the gimplifier can't correctly process, how do you d

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Steven Bosscher
On Tuesday 06 September 2005 15:05, Gabriel Dos Reis wrote: > Richard Guenther <[EMAIL PROTECTED]> writes: > | On 9/6/05, Richard Kenner <[EMAIL PROTECTED]> wrote: > | > I don't think we ever defined "valid GENERIC" that way. > | > > | > About a year ago, when we tried to define it, that's what

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Gabriel Dos Reis
Richard Guenther <[EMAIL PROTECTED]> writes: | On 9/6/05, Richard Kenner <[EMAIL PROTECTED]> wrote: | > I don't think we ever defined "valid GENERIC" that way. | > | > About a year ago, when we tried to define it, that's what we came up | > with. If that isn't the definition, then what *is*?

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Guenther
On 9/6/05, Richard Kenner <[EMAIL PROTECTED]> wrote: > I don't think we ever defined "valid GENERIC" that way. > > About a year ago, when we tried to define it, that's what we came up > with. If that isn't the definition, then what *is*? The problem is that > we have no document that says wh

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Kenner
I don't think we ever defined "valid GENERIC" that way. About a year ago, when we tried to define it, that's what we came up with. If that isn't the definition, then what *is*? The problem is that we have no document that says what is and is not valid GENERIC. At least the proposed defini

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Steven Bosscher
On Tuesday 06 September 2005 14:04, Richard Kenner wrote: > On the > other hand, we define "valid GENERIC" to be those trees that were generated > by the compiler immediately before the tree-ssa conversion and trees of the > above form were generated then. So they are valid GENERIC and ought to be

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Kenner
> # VUSE ; > VIEW_CONVERT_EXPR(*D.861).b = 1; Why are we using a VIEW_CONVERT_EXPR here btw? I'd say D.862 = (struct c34007p__T7b *) D.860; D.862->b = 1; would be a lot more middle-end friendly and maybe not exposing the problem you are seeing? Of co

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Kenner
You want to look at tree-ssa-operands.c:get_expr_operands() and see where things go wrong. Also for D.861 not in SSA form, there might be a missing call to mark_vars_to_rename and/or update_ssa somewhere. At which point in the pass flow does the above happen? Is it ever "correct"

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Guenther
On 9/6/05, Richard Kenner <[EMAIL PROTECTED]> wrote: > Here's a fragment of the SSA dump for a shortened version of that > test. > > > D.860_8 = __gnat_malloc (20); > # D.861_10 = V_MUST_DEF ; > D.861 = (struct c34007p__designated *) D.860_8; > # VUSE ; > VIEW_CONVERT_EXPR(*D.861).b

Re: DCE eliminating valid statement for ACATS c34007p

2005-09-06 Thread Richard Guenther
On 9/6/05, Richard Kenner <[EMAIL PROTECTED]> wrote: > Here's a fragment of the SSA dump for a shortened version of that > test. > > > D.860_8 = __gnat_malloc (20); > # D.861_10 = V_MUST_DEF ; > D.861 = (struct c34007p__designated *) D.860_8; > # VUSE ; > VIEW_CONVERT_EXPR(*D.861).b

DCE eliminating valid statement for ACATS c34007p

2005-09-05 Thread Richard Kenner
Here's a fragment of the SSA dump for a shortened version of that test. D.860_8 = __gnat_malloc (20); # D.861_10 = V_MUST_DEF ; D.861 = (struct c34007p__designated *) D.860_8; # VUSE ; VIEW_CONVERT_EXPR(*D.861).b = 1; # VUSE ; VIEW_CONVERT_EXPR(*D.861).l = 3; There last two s