This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix over-optimization of calls to pure function


> Hi,
> 
> this fixes an over-optimization of the GIMPLE optimizer, whereby two otherwise 
> identical calls to a pure function present in different EH regions are CSEd, 
> which changes the semantics of the program because the second EH handler is 
> not invoked:
> 
>   begin
>     I := F(0);
>   exception
>     when E => N := N + 1;
>   end;
> 
>   begin
>     I := F(0);
>   exception
>     when E => N := N +1;
>   end;
> 
> Two passes (DOM and FRE) can optimize this construct and a test modelled on 
> stmt_can_throw_internal is used to coax them into not doing so.
> 
> Tested on x86_64-suse-linux, OK for the mainline?

Can't I have sometihng like

 loop (i as iterator)
   begin
     I := F(0);
   exception
     when E => N := N + 1;
   end;

here I would expect PRE to discover I as loop invariant that will cause 
exception to be called just once, not at every iteration of loop?
Can't the same happen for non-call expcetions?

Honza


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]