From 1f722e35ab3805de6eeace770508a9085944e93e Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 4 Feb 2022 17:41:55 +0100 Subject: [PATCH] Add optmization testcase for incorrect optimization in Ada gcc/testsuite/ PR tree-optimization/104356 * gnat.dg/opt97.adb: New test. --- gcc/testsuite/gnat.dg/opt97.adb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 gcc/testsuite/gnat.dg/opt97.adb diff --git a/gcc/testsuite/gnat.dg/opt97.adb b/gcc/testsuite/gnat.dg/opt97.adb new file mode 100644 index 0000000..1bf6a75 --- /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" } } -- 2.7.4