public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Finding a relevant place for a custom GCC pass
@ 2014-01-06  6:12 Sandeep K Chaudhary
  2014-01-06  6:24 ` Marc Glisse
  0 siblings, 1 reply; 4+ messages in thread
From: Sandeep K Chaudhary @ 2014-01-06  6:12 UTC (permalink / raw)
  To: gcc-help, gcc

Hi guys,

I want to write a pass which can find the calculations performed on
the right hand side of each statement. In the below example -

        VAR1 = 1;
        VAR1++;
        VAR1 = VAR1 + 5;

I want to be able to capture the equivalent statements i.e.

VAR1 = 1;
VAR1 = 2;
VAR1 = 7;

To achieve this, I dumped various intermediate files using
"-fdump-tree-all'. I looked at all of them manually and found that
either the statements are non-evaluated (during initial stages) or
they are completely optimized, hence losing the intermediate
assignment calculations (during later stages). There is no pass which
generates dumps related to the intermediate assignment calculations.

I am not able to understand where I should aim to place my pass in
order to achieve the above mentioned functionality. Initially, I had
thought of writing IPA pass but I looked at 'copyprop' and 'forwprop'
dumps and saw that everything is optimized to the last statement. I am
not able to understand how a pass should be placed between GIMPLE
stage and later stages so that intermediate calculations such as the
ones mentioned above in the example, can be captured. Please provide
suggestions and help regarding this.

Thanks a lot in advance !

Regards,
Sandeep Chaudhary.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Finding a relevant place for a custom GCC pass
  2014-01-06  6:12 Finding a relevant place for a custom GCC pass Sandeep K Chaudhary
@ 2014-01-06  6:24 ` Marc Glisse
  2014-01-06  6:47   ` Sandeep K Chaudhary
  0 siblings, 1 reply; 4+ messages in thread
From: Marc Glisse @ 2014-01-06  6:24 UTC (permalink / raw)
  To: Sandeep K Chaudhary; +Cc: gcc-help, gcc

On Sun, 5 Jan 2014, Sandeep K Chaudhary wrote:

> Hi guys,
>
> I want to write a pass which can find the calculations performed on
> the right hand side of each statement. In the below example -
>
>        VAR1 = 1;
>        VAR1++;
>        VAR1 = VAR1 + 5;
>
> I want to be able to capture the equivalent statements i.e.
>
> VAR1 = 1;
> VAR1 = 2;
> VAR1 = 7;
>
> To achieve this, I dumped various intermediate files using
> "-fdump-tree-all'. I looked at all of them manually and found that
> either the statements are non-evaluated (during initial stages) or
> they are completely optimized, hence losing the intermediate
> assignment calculations (during later stages). There is no pass which
> generates dumps related to the intermediate assignment calculations.
>
> I am not able to understand where I should aim to place my pass in
> order to achieve the above mentioned functionality. Initially, I had
> thought of writing IPA pass but I looked at 'copyprop' and 'forwprop'
> dumps and saw that everything is optimized to the last statement. I am
> not able to understand how a pass should be placed between GIMPLE
> stage and later stages so that intermediate calculations such as the
> ones mentioned above in the example, can be captured. Please provide
> suggestions and help regarding this.

Short answer: you can't.

You can either have your passe before ccp, and duplicate the functionality 
of ccp, or you can hack the ccp pass to insert your code in it, but I 
doubt there is a suitable plugin hook for that, so you may have to edit 
gcc's source code directly.

If you compile with -g and look at debug statements, the information is 
not completely lost after the pass that optimizes this to just VAR1 = 7, 
but it still wouldn't be convenient to use that for your purpose.

-- 
Marc Glisse

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Finding a relevant place for a custom GCC pass
  2014-01-06  6:24 ` Marc Glisse
@ 2014-01-06  6:47   ` Sandeep K Chaudhary
  2014-01-06 12:20     ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Sandeep K Chaudhary @ 2014-01-06  6:47 UTC (permalink / raw)
  To: gcc-help; +Cc: gcc

Thanks for the reply Marc !

If I place my pass before ccp then I guess I have to implement the
means to perform calculations on my own so that it can duplicate the
functionality of ccp, right? I will also look at the source code to
see if I can modify the source code directly. Is pass_ccp in
tree-ssa-ccp.c the correct one to look at? Please let me know.

Yes, I have tried the second option you suggested. It's not convenient
for my purpose.

Thanks and regards,
Sandeep.

On Sun, Jan 5, 2014 at 10:24 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> On Sun, 5 Jan 2014, Sandeep K Chaudhary wrote:
>
>> Hi guys,
>>
>> I want to write a pass which can find the calculations performed on
>> the right hand side of each statement. In the below example -
>>
>>        VAR1 = 1;
>>        VAR1++;
>>        VAR1 = VAR1 + 5;
>>
>> I want to be able to capture the equivalent statements i.e.
>>
>> VAR1 = 1;
>> VAR1 = 2;
>> VAR1 = 7;
>>
>> To achieve this, I dumped various intermediate files using
>> "-fdump-tree-all'. I looked at all of them manually and found that
>> either the statements are non-evaluated (during initial stages) or
>> they are completely optimized, hence losing the intermediate
>> assignment calculations (during later stages). There is no pass which
>> generates dumps related to the intermediate assignment calculations.
>>
>> I am not able to understand where I should aim to place my pass in
>> order to achieve the above mentioned functionality. Initially, I had
>> thought of writing IPA pass but I looked at 'copyprop' and 'forwprop'
>> dumps and saw that everything is optimized to the last statement. I am
>> not able to understand how a pass should be placed between GIMPLE
>> stage and later stages so that intermediate calculations such as the
>> ones mentioned above in the example, can be captured. Please provide
>> suggestions and help regarding this.
>
>
> Short answer: you can't.
>
> You can either have your passe before ccp, and duplicate the functionality
> of ccp, or you can hack the ccp pass to insert your code in it, but I doubt
> there is a suitable plugin hook for that, so you may have to edit gcc's
> source code directly.
>
> If you compile with -g and look at debug statements, the information is not
> completely lost after the pass that optimizes this to just VAR1 = 7, but it
> still wouldn't be convenient to use that for your purpose.
>
> --
> Marc Glisse



-- 
Thanks and regards,
Sandeep K Chaudhary.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Finding a relevant place for a custom GCC pass
  2014-01-06  6:47   ` Sandeep K Chaudhary
@ 2014-01-06 12:20     ` Richard Biener
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2014-01-06 12:20 UTC (permalink / raw)
  To: Sandeep K Chaudhary, gcc-help; +Cc: gcc

Sandeep K Chaudhary <babbusandy2006@gmail.com> wrote:
>Thanks for the reply Marc !
>
>If I place my pass before ccp then I guess I have to implement the
>means to perform calculations on my own so that it can duplicate the
>functionality of ccp, right? I will also look at the source code to
>see if I can modify the source code directly. Is pass_ccp in
>tree-ssa-ccp.c the correct one to look at? Please let me know.

Yes. You want to look at the il before substitute_and_fold together with the ccp lattice.

Richard.

>Yes, I have tried the second option you suggested. It's not convenient
>for my purpose.
>
>Thanks and regards,
>Sandeep.
>
>On Sun, Jan 5, 2014 at 10:24 PM, Marc Glisse <marc.glisse@inria.fr>
>wrote:
>> On Sun, 5 Jan 2014, Sandeep K Chaudhary wrote:
>>
>>> Hi guys,
>>>
>>> I want to write a pass which can find the calculations performed on
>>> the right hand side of each statement. In the below example -
>>>
>>>        VAR1 = 1;
>>>        VAR1++;
>>>        VAR1 = VAR1 + 5;
>>>
>>> I want to be able to capture the equivalent statements i.e.
>>>
>>> VAR1 = 1;
>>> VAR1 = 2;
>>> VAR1 = 7;
>>>
>>> To achieve this, I dumped various intermediate files using
>>> "-fdump-tree-all'. I looked at all of them manually and found that
>>> either the statements are non-evaluated (during initial stages) or
>>> they are completely optimized, hence losing the intermediate
>>> assignment calculations (during later stages). There is no pass
>which
>>> generates dumps related to the intermediate assignment calculations.
>>>
>>> I am not able to understand where I should aim to place my pass in
>>> order to achieve the above mentioned functionality. Initially, I had
>>> thought of writing IPA pass but I looked at 'copyprop' and
>'forwprop'
>>> dumps and saw that everything is optimized to the last statement. I
>am
>>> not able to understand how a pass should be placed between GIMPLE
>>> stage and later stages so that intermediate calculations such as the
>>> ones mentioned above in the example, can be captured. Please provide
>>> suggestions and help regarding this.
>>
>>
>> Short answer: you can't.
>>
>> You can either have your passe before ccp, and duplicate the
>functionality
>> of ccp, or you can hack the ccp pass to insert your code in it, but I
>doubt
>> there is a suitable plugin hook for that, so you may have to edit
>gcc's
>> source code directly.
>>
>> If you compile with -g and look at debug statements, the information
>is not
>> completely lost after the pass that optimizes this to just VAR1 = 7,
>but it
>> still wouldn't be convenient to use that for your purpose.
>>
>> --
>> Marc Glisse


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-01-06 12:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-06  6:12 Finding a relevant place for a custom GCC pass Sandeep K Chaudhary
2014-01-06  6:24 ` Marc Glisse
2014-01-06  6:47   ` Sandeep K Chaudhary
2014-01-06 12:20     ` Richard Biener

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).