From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 800C13856978 for ; Thu, 7 Jul 2022 08:49:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 800C13856978 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 9FE9E1FD5C for ; Thu, 7 Jul 2022 08:49:31 +0000 (UTC) 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 99A752C141 for ; Thu, 7 Jul 2022 08:49:31 +0000 (UTC) Date: Thu, 7 Jul 2022 08:49:31 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] target/106219 - proprly mark builtins pure via ix86_add_new_builtins 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.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2022 08:49:33 -0000 Message-ID: <20220707084931.eCOoVMX1lnGIa8V9-RqI7oCssIJLFRI0NgS9XOBy5Po@z> The target optimize pragma path to initialize extra target specific builtins missed handling of the pure_p flag which in turn causes extra clobber side-effects of gather builtins leading to unexpected issues downhill. Bootstrap and regtest running on x86_64-unknown-linux-gnu, will push as obvious if that succeeds. * config/i386/i386-builtins.cc (ix86_add_new_builtins): Properly set DECL_PURE_P. * g++.dg/pr106219.C: New testcase. --- gcc/config/i386/i386-builtins.cc | 2 ++ gcc/testsuite/g++.dg/pr106219.C | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 gcc/testsuite/g++.dg/pr106219.C diff --git a/gcc/config/i386/i386-builtins.cc b/gcc/config/i386/i386-builtins.cc index 96743e6122d..fe7243c3837 100644 --- a/gcc/config/i386/i386-builtins.cc +++ b/gcc/config/i386/i386-builtins.cc @@ -385,6 +385,8 @@ ix86_add_new_builtins (HOST_WIDE_INT isa, HOST_WIDE_INT isa2) ix86_builtins[i] = decl; if (ix86_builtins_isa[i].const_p) TREE_READONLY (decl) = 1; + if (ix86_builtins_isa[i].pure_p) + DECL_PURE_P (decl) = 1; } } diff --git a/gcc/testsuite/g++.dg/pr106219.C b/gcc/testsuite/g++.dg/pr106219.C new file mode 100644 index 00000000000..3cad1507d5f --- /dev/null +++ b/gcc/testsuite/g++.dg/pr106219.C @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-O3" } +// { dg-additional-options "-march=bdver2" { target x86_64-*-* } } + +int max(int __b) { + if (0 < __b) + return __b; + return 0; +} +struct Plane { + Plane(int, int); + int *Row(); +}; +#ifdef __x86_64__ +#pragma GCC target "sse2,ssse3,avx,avx2" +#endif +float *ConvolveXSampleAndTranspose_rowp; +int ConvolveXSampleAndTranspose_res, ConvolveXSampleAndTranspose_r; +void ConvolveXSampleAndTranspose() { + Plane out(0, ConvolveXSampleAndTranspose_res); + for (int y;;) { + float sum; + for (int i = ConvolveXSampleAndTranspose_r; i; ++i) + sum += i; + for (; ConvolveXSampleAndTranspose_r; ++ConvolveXSampleAndTranspose_r) + sum += + ConvolveXSampleAndTranspose_rowp[max(ConvolveXSampleAndTranspose_r)] * + ConvolveXSampleAndTranspose_r; + out.Row()[y] = sum; + } +} -- 2.35.3