I believe the project configurations in which the optimization causes problems 
might be too common to add it to a flag like that from the get-go. Andi Kleen 
suggested on the gcc thread, to have the use of the optimization be dependent 
on -fno-semtantic-interposition, -flto and -fwhole-program which I also think 
would be better. Not my call though and not really sure what would be good, so 
any insight/discussion regarding this would be appreciated!

________________________________
From: Martin Jambor <mjam...@suse.cz>
Sent: 15 July 2025 10:39:12
To: Jonathan Wakely; Thomas de Bock
Cc: gcc@gcc.gnu.org
Subject: [ext] Re: Addition of compiler flag for dynamic_cast optimization

On Mon, Jul 14 2025, Jonathan Wakely via Gcc wrote:
> On Mon, 14 Jul 2025 at 14:57, Thomas de Bock via Gcc <gcc@gcc.gnu.org> wrote:
>>
>> Hello all, I've been looking into a compiler optimization implemented by 
>> clang but not gcc that substitutes a __dynamic_cast call for a simple vtable 
>> ptr comparison in the case that the class being cast to is final.
>>
>> However this brings issues with it in some cases (specified in thread). I 
>> believe having the optimization disabled by default, but adding a compiler 
>> flag to enable it would be ideal. Code for the optimization is mostly done 
>> so I'm looking to have this optimization available in gcc somehow now, 
>> interested in hearing any opinions on this :)
>>
>> thread link: 
>> https://urldefense.com/v3/__https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63164*add_comment__;Iw!!EvhwMw!Q1yT3rQLCeKTTwOjgVjBcHYyWd1D3la3hd8rCJ76p7kJdrgVNR5-s3IcjWSt8EoXPeDZXeFAPsED3EY$
>
> I agree that we don't want to perform the optimization by default, but
> it would be useful to have an option to enable it when you know it's
> safe to do so.

If it materializes in this form, could we include it in -Ofast?

Thanks,

Martin

This e-mail and any attachments may contain information that is confidential 
and proprietary and otherwise protected from disclosure. If you are not the 
intended recipient of this e-mail, do not read, duplicate or redistribute it by 
any means. Please immediately delete it and any attachments and notify the 
sender that you have received it by mistake. Unintended recipients are 
prohibited from taking action on the basis of information in this e-mail or any 
attachments. The DRW Companies make no representations that this e-mail or any 
attachments are free of computer viruses or other defects.

Reply via email to