On 03/06/2018 09:28 AM, Richard Biener wrote:
> On Tue, Mar 6, 2018 at 1:00 PM, Prathamesh Kulkarni
> <prathamesh.kulka...@linaro.org> wrote:
>> Hi,
>> For the following test-case,
>>
>> int a;
>>
>> __attribute__((noinline))
>> static void foo()
>> {
>>   a = 3;
>> }
>>
>> int main()
>> {
>>   a = 4;
>>   foo ();
>>   return a;
>> }
>>
>> I assume it's safe to remove "a = 4"  since 'a' would be overwritten
>> by call to foo ?
>> IIUC, ipa-reference pass does mod/ref analysis to compute side-effects
>> of function call,
>> so could we perhaps use ipa_reference_get_not_written_global() in dse
>> pass to check if a global variable will be killed on call to a
>> function ? If not, I suppose we could write a similar ipa pass that
>> computes the set of killed global variables per function but I am not
>> sure if that's the correct approach.
> 
> Do you think the situation happens often enough to make this worthwhile?
> 
> ipa-reference doesn't compute must-def, only may-def and may-use IIRC.
> 
> Richard.
> 
>> Thanks,
>> Prathamesh

This dead write optimization sounds similar to "DeadSpy: a tool to pinpoint 
program inefficiencies" by Milind Chabbi and John Mellor-Crummey of Rice 
University:

https://dl.acm.org/citation.cfm?id=2259033

The abstract says there were numerous dead writes in the SPEC 2006 gcc 
benchmark and eliminating those provided average 15% improvement in performance.

-Will

Reply via email to