From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 699653858406 for ; Mon, 7 Nov 2022 10:36:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 699653858406 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667817365; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=ummYGHmNcimaikkWJdgU14mk07KFA4UENeuCLj75wpg=; b=NH9ZYUNONCnm+Ch1sEux5ZJgBa1nfJsi84CzUEcnHwHdx2TKprE9m7IzRgS1vn5GpZ4Zsa 4co3OPE21iS5/lXKki8rWi18R+EwUxQjyJEFql9Al1J9sffXnWqNQabDZJ/1NGE8j0EhL9 Eq7qNSNMf956figFSXqMA/VwFDyBmQo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-524-EfLdz14MNuS7k_J3MKLTzA-1; Mon, 07 Nov 2022 05:36:03 -0500 X-MC-Unique: EfLdz14MNuS7k_J3MKLTzA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 912D7101AA6A; Mon, 7 Nov 2022 10:36:03 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 50F464221F; Mon, 7 Nov 2022 10:36:03 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 2A7Aa0tk376008 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 7 Nov 2022 11:36:01 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2A7AZxGc376007; Mon, 7 Nov 2022 11:35:59 +0100 Date: Mon, 7 Nov 2022 11:35:59 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org, rth@gcc.gnu.org Subject: Re: [PATCH][RFC] tree-optimization/107389 - use __builtin_assume_alignment at -O0 Message-ID: Reply-To: Jakub Jelinek References: <20221107090211.E59EA13494@imap2.suse-dmz.suse.de> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Nov 07, 2022 at 10:31:21AM +0000, Richard Biener wrote: > On Mon, 7 Nov 2022, Jakub Jelinek wrote: > > > On Mon, Nov 07, 2022 at 10:02:11AM +0100, Richard Biener wrote: > > > The following adds a fold_builtins pass at -O0, keying off some > > > unwanted optimization and setting pointer alignment of the result > > > of __builtin_assume_alignment before removing the call. This > > > allows libatomic calls to be elided at -O0 on s390 for > > > > > > __uint128_t foo(__uint128_t *p) > > > { > > > return __atomic_load_n((__uint128_t *)__builtin_assume_aligned (p, 16), 0); > > > } > > > > > > not sure how to reliably test this though. > > > > > > Thoughts? > > > > Do we really need a separate pass for it? > > Can't we do it say during gimplification? > > gimplification would be too early for always inline - of course since > we don't do any copy propagation the source pattern this works reliably > are limited, mostly when used directly as arguments like in the example > above. Yeah, that was exactly my thinking, because we don't copy propagate at -O0, it will only handle cases where there is exactly one SSA_NAME involved. The advantage of doing it at gimplification time is that we don't need to add an extra pass for -O0. > So yes, the specific case in question would work when we elide > __builtin_assume_aligned during gimplification at -O0 (or during > the GIMPLE lower pass). > > Would you prefer that? Richard, would that work for you? Jakub