On 13 April 2010 12:23, Richard Guenther <richard.guent...@gmail.com> wrote:
> On Tue, Apr 13, 2010 at 12:15 PM, Bingfeng Mei <b...@broadcom.com> wrote:
>>>
>>> Surely printf writes to global memory (it clobbers the stdout FILE*)
>>>
>> OK, the point is not about whether printf is pure or not. Instead, if
>> programmer knows the callee function such as printf contains no
>> memory access that affects operations inside caller function, and he
>> would like to have a way to optimize the code. Our engineer gave following
>> example:
>>
>>    void myfunc(MyStruct *myStruct)
>>    {
>>      int a,b;
>>      a = myStruct->a;
>>      printf("a=%d\n",a);
>>      b = 2*mystruct->a;      // I would like to have the compiler acting as 
>> if I had written b = 2*a;
>>     ...
>>    }
>> Providing such attribute may be potentially dangerous. But it is just
>> like "restrict" qualifier and some other attributes, putting responsibilty
>> of correctness on the programmer. "novops" seems to achieve that effect,
>> though its semantics doesn't match exactly what I described.
>
> Indeed.  IPA pointer analysis will probably figure it out
> automagically - that *myStruct didn't escape the unit.
> Being able to annotate incoming pointers this way would
> maybe be useful.

This is
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31893

isn't it?

Cheers,

Manuel.

Reply via email to