From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25806 invoked by alias); 1 Aug 2012 17:14:48 -0000 Received: (qmail 25790 invoked by uid 22791); 1 Aug 2012 17:14:46 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 01 Aug 2012 17:14:33 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 6B772A3B99; Wed, 1 Aug 2012 19:14:32 +0200 (CEST) Date: Wed, 01 Aug 2012 17:14:00 -0000 From: Richard Guenther To: Richard Henderson Cc: uweigand@de.ibm.com, gcc-patches@gcc.gnu.org Subject: Re: [PATCH 0/2] Convert s390 to atomic optabs, v2 In-Reply-To: <5019524D.8070300@redhat.com> Message-ID: References: <5016C81E.5020709@redhat.com> <1343687574-3244-1-git-send-email-rth@redhat.com> <5017FD48.8080005@redhat.com> <5019524D.8070300@redhat.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-08/txt/msg00042.txt.bz2 On Wed, 1 Aug 2012, Richard Henderson wrote: > On 08/01/2012 01:40 AM, Richard Guenther wrote: > > I see. So your issue is that you don't get the knowledge > > that the address is even more aligned than required by the > > builtin. > > Yes. Very helpful for quite a few targets that only have word-sized atomic operations, and we emulate char/short via bit-fiddling. That's where MEM_ALIGN as an align+ofs pair would come in doubly helpful... > > > So we only use type information when seeing an actual memory > > reference where we make sure to keep alignment info correct > > (which we don't bother to do for addresses). > > How hard would it be to include (some) builtins in "actual memory reference"? Since it seems likely at this point that gimple_atomic will make it in for 4.8? Actually it would not help you at all. As far as I understand the testcase is equivalent from an alignment perspective to struct S { int x; unsigned short y; } g_s; void bad (S *p_s) { short *p = (short *)&p_s->y; *(short *)p = 0; } so the builtin is a memory access to a short. We cannot derive any alignment for p_s from this alone unless we change the way the middle-end constrains pointer type usage (which in turn means that pointer conversions cannot be dropped on the floor like we do now). If you said p_s->y = 0; then we can exploit the fact that you dereference p_s and derive bigger alignment. But I don't see how we can massage the builtin to preserve such form. Well, put in a memory reference in the argument, __builtin_compare_exchange (p_s->y, ...), but that fails foul of GIMPLE requirements to use a temporary for register type function arguments, which we may be able to overcome with some special flags. Richard.