From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 913D13858C52; Tue, 13 Feb 2024 12:48:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 913D13858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707828534; bh=eHDTQCAsroSOUrKEzDPVtitsMYayOuarBpb6LZ+f7MU=; h=From:To:Subject:Date:From; b=PXK4Q1c6RbBgZP/P/f35Z0uEm0bFK3F1M/c73a4KV3eGAqHZO1ScnPBYMlbg9bPWP 4r42+oiKKN/uAcmdtlHbNyvr5++YK7IFw5kNcC5fdWStZ91wGM4eVj8fgBh9I0nf99 mKNFeUpZYZceyfErdHL5fpxqZEh5WboOCbICxCeU= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-8323] tree-optimization/113896 - testcase for fixed PR X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: d85a658402d5433ff223ce8f4e70174ed8a20428 X-Git-Newrev: 8a93dc34e90cd8e2bb073f8fd48f671aea62d965 Message-Id: <20240213124854.913D13858C52@sourceware.org> Date: Tue, 13 Feb 2024 12:48:54 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8a93dc34e90cd8e2bb073f8fd48f671aea62d965 commit r13-8323-g8a93dc34e90cd8e2bb073f8fd48f671aea62d965 Author: Richard Biener Date: Tue Feb 13 13:39:29 2024 +0100 tree-optimization/113896 - testcase for fixed PR The SLP permute optimization rewrite fixed this. PR tree-optimization/113896 * g++.dg/torture/pr113896.C: New testcase. (cherry picked from commit 4a1cd5560b9b545eb848eb1d1e06d345fb606f76) Diff: --- gcc/testsuite/g++.dg/torture/pr113896.C | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gcc/testsuite/g++.dg/torture/pr113896.C b/gcc/testsuite/g++.dg/torture/pr113896.C new file mode 100644 index 000000000000..534c1c2e1cce --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr113896.C @@ -0,0 +1,35 @@ +// { dg-do run } +// { dg-additional-options "-ffast-math" } + +double a1 = 1.0; +double a2 = 1.0; + +void __attribute__((noipa)) +f(double K[2], bool b) +{ + double A[] = { + b ? a1 : a2, + 0, + 0, + 0 + }; + + double sum{}; + for(double a : A) sum += a; + for(double& a : A) a /= sum; + + if (b) { + K[0] = A[0]; // 1.0 + K[1] = A[1]; // 0.0 + } else { + K[0] = A[0] + A[1]; + } +} + +int main() +{ + double K[2]{}; + f(K, true); + if (K[0] != 1. || K[1] != 0.) + __builtin_abort (); +}