From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 50A0A3858C2F for ; Tue, 8 Nov 2022 13:38:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 50A0A3858C2F 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-out1.suse.de (Postfix) with ESMTP id 3F59D22465; Tue, 8 Nov 2022 13:38:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1667914707; 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=D7CdSG+LhbyBJxVbU8gO3Bd1NDY9qPU4kdZAVUh14pI=; b=mEyyuqumigeRTT5704l+E1Car/NYGdIEH6maBQNgOWgESrIjJCweCzYevoTvyUMgk/0NHe hlVz9sXr5jiL1LNry8h+svuRS/1A92IVDcCpEIEgb5OBaTA1GD2MtwuSwmPHEvctUZHycZ Sa3uG6Ub3xWBslwemw6Ju/WSnFwXzmg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1667914707; 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=D7CdSG+LhbyBJxVbU8gO3Bd1NDY9qPU4kdZAVUh14pI=; b=/KWo9HDanJiEVnP2B4KynQLoky0rsQzzJqiq/t1mfIriePZUJcjRNZcSRlIS60lA9pjIcM 1yZZtoI/3gCDBEAw== 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 39A862C141; Tue, 8 Nov 2022 13:38:27 +0000 (UTC) Date: Tue, 8 Nov 2022 13:38:27 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH][v2] tree-optimization/107389 - honor __builtin_assume_alignment at -O0 In-Reply-To: Message-ID: References: <20221108125348.BFC2213398@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=-10.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham 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 Tue, 8 Nov 2022, Jakub Jelinek wrote: > On Tue, Nov 08, 2022 at 01:53:48PM +0100, Richard Biener wrote: > > The following makes sure to set alignment information on the LHS > > of __builtin_assume_alignment calls even when not optimizing so > > uses as arguments to builtin functions like memcpy or __atomic_load_n > > can be reflected at RTL expansion time. > > > > Bootstrap and regtest running on x86_64-unknown-linux-gnu, OK? > > > > Thanks, > > Richard. > > > > PR tree-optimization/107389 > > * gimple-low.cc (lower_builtin_assume_aligned): New. > > (lower_stmt): Call it. > > > > * gcc.dg/pr107389.c: New testcase. > > --- > > gcc/gimple-low.cc | 41 +++++++++++++++++++++++++++++++++ > > gcc/testsuite/gcc.dg/pr107389.c | 13 +++++++++++ > > 2 files changed, 54 insertions(+) > > create mode 100644 gcc/testsuite/gcc.dg/pr107389.c > > > > diff --git a/gcc/gimple-low.cc b/gcc/gimple-low.cc > > index 512aa9feada..f9bcb772163 100644 > > --- a/gcc/gimple-low.cc > > +++ b/gcc/gimple-low.cc > > @@ -84,6 +84,7 @@ static void lower_try_catch (gimple_stmt_iterator *, struct lower_data *); > > static void lower_gimple_return (gimple_stmt_iterator *, struct lower_data *); > > static void lower_builtin_setjmp (gimple_stmt_iterator *); > > static void lower_builtin_posix_memalign (gimple_stmt_iterator *); > > +static void lower_builtin_assume_aligned (gimple_stmt_iterator *); > > > > > > /* Lower the body of current_function_decl from High GIMPLE into Low > > @@ -768,6 +769,13 @@ lower_stmt (gimple_stmt_iterator *gsi, struct lower_data *data) > > lower_builtin_posix_memalign (gsi); > > return; > > } > > + else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_ASSUME_ALIGNED > > + && !optimize) > > + { > > + lower_builtin_assume_aligned (gsi); > > + data->cannot_fallthru = false; > > + return; > > + } > > } > > > > if (decl && (flags_from_decl_or_type (decl) & ECF_NORETURN)) > > @@ -1310,6 +1318,39 @@ lower_builtin_posix_memalign (gimple_stmt_iterator *gsi) > > gsi_insert_after (gsi, stmt, GSI_NEW_STMT); > > gsi_insert_after (gsi, gimple_build_label (noalign_label), GSI_NEW_STMT); > > } > > + > > +/* Lower calls to __builtin_assume_aligned when not optimizing. */ > > + > > +static void > > +lower_builtin_assume_aligned (gimple_stmt_iterator *gsi) > > +{ > > + gcall *call = as_a (gsi_stmt (*gsi)); > > + > > + tree lhs = gimple_call_lhs (call); > > + if (!lhs || !POINTER_TYPE_P (TREE_TYPE (lhs))) > > + return; > > I think nothing checks that TREE_CODE (lhs) == SSA_NAME, > that isn't guaranteed before ssa pass. Yep, noticed in the testsuite and fixed. Richard.