Tree tail merging breaks __builtin_unreachable optimization
Tom de Vries
Tom_deVries@mentor.com
Thu Jul 5 18:46:00 GMT 2012
On 05/07/12 15:30, Michael Matz wrote:
> Hi,
>
> On Thu, 5 Jul 2012, Tom de Vries wrote:
>
>> The asserts allow the return result to be optimized, but not the cfg
>> conditions.
>>
>> AFAIU, we can insert the asserts earlier. F.i., we can insert
>> aD.1711_6 = ASSERT_EXPR <aD.1711_1(D), aD.1711_1(D) > 0>
>> before the GIMPLE_COND in bb2.
>
> Nope. That would require some more checks, in particular that the BB
> containing builtin_unreachable doesn't contain any other side-effects.
> Given this:
>
> if (i < 0)
> { do_something_interesting();
> __builtin_unreachable();
> }
>
> moving the assert before the if would remove the if condition, hence
> the call to do_something_interesting. You need to retain side-effects if
> there are any.
>
Michael,
Thanks for pointing that out.
I tried a first stab at your suggestion of implementing the optimization in
pass_fold_builtins, it works for the test-case.
Thanks,
- Tom
>
> Ciao,
> Michael.
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ccp-unreachable.patch
Type: text/x-patch
Size: 1775 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120705/1e918874/attachment.bin>
More information about the Gcc-patches
mailing list