From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id E024E385829D; Tue, 13 Feb 2024 12:42:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E024E385829D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707828154; bh=q+ABDSzibK+tAN5CceYNbrN2OuuP/LUAzmBe5HmPRD0=; h=From:To:Subject:Date:From; b=sX9dm2s8sr+ywqHaIWLsSl8s2z+UX7CZPGYGQ0cI5LOsChUvbNVuqur/AB+bZq6kO DNA9gmsBycmAcBmH86fUJtnWmmHAyk51w0knTAtm+4F8U188TnZ8Pw+E1v5Ml/QQUS ov4egAWvzq0MKsH/LzNNNiFcCUWGv+5grFTwSZHc= 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 r14-8957] tree-optimization/113896 - testcase for fixed PR X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 94225dfb5623725fa519eac69338f7a632a509ae X-Git-Newrev: 4a1cd5560b9b545eb848eb1d1e06d345fb606f76 Message-Id: <20240213124234.E024E385829D@sourceware.org> Date: Tue, 13 Feb 2024 12:42:34 +0000 (GMT) List-Id: https://gcc.gnu.org/g:4a1cd5560b9b545eb848eb1d1e06d345fb606f76 commit r14-8957-g4a1cd5560b9b545eb848eb1d1e06d345fb606f76 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. 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 (); +}