This is the mail archive of the
mailing list for the GCC project.
Re: Re: Why does gcc generate const local array on stack?
- From: Bingfeng Mei <bingfeng dot mei at broadcom dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Jonathan Wakely <jwakely dot gcc at gmail dot com>, lh_mouse <lh_mouse at 126 dot com>, gcc <gcc at gcc dot gnu dot org>
- Date: Thu, 21 Apr 2016 14:04:05 +0100
- Subject: Re: Re: Why does gcc generate const local array on stack?
- Authentication-results: sourceware.org; auth=none
- References: <CAAvcwYdM4AR0JjN4pY=xndyYAmgLTQ8i54EzeUrj4L=wtGBAog at mail dot gmail dot com> <31a6f6bf dot e3788 dot 15434b9ee28 dot Coremail dot lh_mouse at 126 dot com> <CAH6eHdRbbAZodOqt0kyQHk51Xkb0fs8W7TRCkjaWXd4DPcZPSw at mail dot gmail dot com> <744b2890 dot e5490 dot 15436b1f476 dot Coremail dot lh_mouse at 126 dot com> <CAH6eHdTHsSddkFSo6NQGo5gP+ezn3oDwHfOqr73XDzBNym_rvw at mail dot gmail dot com> <CAFiYyc294WXFqg9cwAGFNbY+Aj-mKbU-bcKjK0xHKyU74y0GKQ at mail dot gmail dot com>
Richard, thanks for explanation. I found an option
-fmerge-all-constants, which can help me work around for now.
On Thu, Apr 21, 2016 at 11:15 AM, Richard Biener
> On Thu, Apr 21, 2016 at 11:39 AM, Jonathan Wakely <firstname.lastname@example.org> wrote:
>> On 21 April 2016 at 03:41, lh_mouse wrote:
>>> See this example: http://coliru.stacked-crooked.com/a/048b4aa5046da11b
>>> In this example the function is called recursively.
>> See the original email you replied to:
>> "I understand if this function is recursive and pointer of the array
>> is involved, GCC would have to maintain the array on stack and hence
>> the initialization."
>> The question is about cases where that doesn't happen.
> The decision on whether to localize the array and inline the init is
> done at gimplification time.
> The plan is to delay this until SRA which could then also apply the
> desired optimization
> of removing the local in case it is never written to.