From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1285) id 18DA73858D28; Fri, 4 Feb 2022 16:45:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 18DA73858D28 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Eric Botcazou To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7058] Add optmization testcase for incorrect optimization in Ada X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/master X-Git-Oldrev: f62156eab7b757d1ee03a11d5c96c72bd3de079c X-Git-Newrev: 1f722e35ab3805de6eeace770508a9085944e93e Message-Id: <20220204164506.18DA73858D28@sourceware.org> Date: Fri, 4 Feb 2022 16:45:06 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Feb 2022 16:45:06 -0000 https://gcc.gnu.org/g:1f722e35ab3805de6eeace770508a9085944e93e commit r12-7058-g1f722e35ab3805de6eeace770508a9085944e93e Author: Eric Botcazou Date: Fri Feb 4 17:41:55 2022 +0100 Add optmization testcase for incorrect optimization in Ada gcc/testsuite/ PR tree-optimization/104356 * gnat.dg/opt97.adb: New test. Diff: --- gcc/testsuite/gnat.dg/opt97.adb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/gcc/testsuite/gnat.dg/opt97.adb b/gcc/testsuite/gnat.dg/opt97.adb new file mode 100644 index 00000000000..1bf6a750d75 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt97.adb @@ -0,0 +1,25 @@ +-- { dg-do compile } +-- { dg-options "-O2 -fdump-tree-optimized" } + +with System.Unsigned_Types; use System.Unsigned_Types; + +function Opt97 (X, Y : Unsigned) return Unsigned is + + pragma Suppress (All_Checks); + + Z : Unsigned; + +begin + if X >= 2 then + return 0; + end if; + + Z := Y; + if X = 1 then + Z := Y + 4; + end if; + + return Z / X; +end; + +-- { dg-final { scan-tree-dump "/" "optimized" } }