From: Eric Botcazou Date: Fri, 4 Feb 2022 16:41:55 +0000 (+0100) Subject: Add optmization testcase for incorrect optimization in Ada X-Git-Tag: basepoints/gcc-13~1255 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1f722e35ab3805de6eeace770508a9085944e93e;p=thirdparty%2Fgcc.git Add optmization testcase for incorrect optimization in Ada gcc/testsuite/ PR tree-optimization/104356 * gnat.dg/opt97.adb: New test. --- diff --git a/gcc/testsuite/gnat.dg/opt97.adb b/gcc/testsuite/gnat.dg/opt97.adb new file mode 100644 index 000000000000..1bf6a750d75d --- /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" } }