From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10042 invoked by alias); 6 Feb 2014 10:32:42 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 9995 invoked by uid 48); 6 Feb 2014 10:32:39 -0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/60092] posix_memalign not recognized to derive alias and alignment info Date: Thu, 06 Feb 2014 10:32:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: alias, missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-02/txt/msg00559.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60092 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek --- Well, the problem with doing it this way is that ptr is still considered address taken and the assume aligned then really can result in a noop move. What I meant is expand: ret = posix_memalign (&ptr, align, size); as { void *temp; ret = posix_memalign (&temp, align, size); void *temp2 = __builtin_passthru_attribute_malloc_size (temp, size); ptr = __typeof (ptr) __builtin_assume_aligned (temp2, align); temp ={v}{CLOBBER}; } The advantages of doing it this way would be that (if ptr is not address taken for other reasons) that it would not need to be address taken, escape and all the like, I think posix_memalign is not reading the old content of the pointer nor storing it anywhere, it just fills it in as another result, just by reference. And the optimizers would know it doesn't alias anything, like if it came from malloc (size);, and is aligned to align bytes at least. The disadvantage would be that if ptr is addressable for other reasons, we wouldn't reuse it's address for posix_memalign, but pass address of another temporary and then copied the mem.