From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 9BCEE3858D38; Mon, 7 Nov 2022 10:31:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9BCEE3858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 90F391F897; Mon, 7 Nov 2022 10:31:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1667817081; h=from:from:reply-to: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=AWk8CdfcHdLT6AHKcEdsjMliGiQwywIIEgdUliB2wTE=; b=yyzHWF0s/tArDOsM++i2b011y84UE8ImITjaqssiutto/20R3s/8SBMeXwBluK4bVV3+bH 0rUJzToucMnVfKR5PqsQ9zwB38deGQOuvypbXASRY3bFzSb+2Sxa+9Iu823IDA/XY51J5R NMgkzga+xwS3CuMr8HEvwSIDxfzkQfE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1667817081; h=from:from:reply-to: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=AWk8CdfcHdLT6AHKcEdsjMliGiQwywIIEgdUliB2wTE=; b=EkRu1KMIYd7NitzmVYhTixPy1jIrxE+9b0e85O8Fo+K4Spg+PtftAnEJZoaLHZjMIZszgW bXrDXZTJPKm/LBBw== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 6E6932C141; Mon, 7 Nov 2022 10:31:21 +0000 (UTC) Date: Mon, 7 Nov 2022 10:31:21 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: gcc-patches@gcc.gnu.org, rth@gcc.gnu.org Subject: Re: [PATCH][RFC] tree-optimization/107389 - use __builtin_assume_alignment at -O0 In-Reply-To: Message-ID: References: <20221107090211.E59EA13494@imap2.suse-dmz.suse.de> User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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, 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. 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? Thanks, Richard. > > PR tree-optimization/107389 > > * tree-pass.h (pass_fold_builtins_O0): Declare. > > * passes.def (pass_fold_builtins_O0): Schedule. > > * tree-ssa-ccp.cc (pass_fold_builtins_O0): Define. > > (pass_fold_builtins): Template, add gate. > > (pass_fold_builtins::execute): Apply alignment to the > > target of __builtin_assume_aligned at -O0. Disable most > > optimizations for the -O0 pass instance. > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)