https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82390

            Bug ID: 82390
           Summary: gcc.dg/torture tests run with same optimization level
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: testsuite
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

The gcc.dg/torture testsuite contains some tests that set optimization level
explicitly:
...
$ grep 'dg-options.*-O' gcc/testsuite/gcc.dg/torture/*
gcc/testsuite/gcc.dg/torture/cris-asm-mof-1.c:/* { dg-options "-O2 -march=v10"
} */
gcc/testsuite/gcc.dg/torture/pr36244.c:/* { dg-options "-O3
-ftree-parallelize-loops=4" } */
gcc/testsuite/gcc.dg/torture/pr68906.c:/* { dg-options "-O3" } */
gcc/testsuite/gcc.dg/torture/pr69760.c:/* { dg-options "-O2" } */
gcc/testsuite/gcc.dg/torture/pr70935.c:/* { dg-options "-O3 -g" } */
gcc/testsuite/gcc.dg/torture/pr77916.c:/* { dg-options "-O3
-Wno-int-conversion" } */
gcc/testsuite/gcc.dg/torture/pr77937-1.c:/* { dg-options "-O3" } */
gcc/testsuite/gcc.dg/torture/pr77937-2.c:/* { dg-options "-O3" } */
...

If we run one of those tests, the summary suggests that all optimization levels
were used:
...
PASS: gcc.dg/torture/pr36244.c   -O0  (test for excess errors)
PASS: gcc.dg/torture/pr36244.c   -O1  (test for excess errors)
PASS: gcc.dg/torture/pr36244.c   -O2  (test for excess errors)
PASS: gcc.dg/torture/pr36244.c   -O3 -fomit-frame-pointer -funroll-loops
-fpeel-loops -ftracer -finline-functions  (test for excess errors)
PASS: gcc.dg/torture/pr36244.c   -O3 -g  (test for excess errors)
PASS: gcc.dg/torture/pr36244.c   -Os  (test for excess errors)
PASS: gcc.dg/torture/pr36244.c   -O2 -flto -fno-use-linker-plugin
-flto-partition=none  (test for excess errors)
PASS: gcc.dg/torture/pr36244.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  (test for excess errors)
...

But we see that in fact the dg-options setting takes precedence:
...
build/gcc/xgcc -Bbuild/gcc/ gcc/testsuite/gcc.dg/torture/pr36244.c   
-fno-diagnostics-show-caret -fdiagnostics-color=never    -O0  -O3
-ftree-parallelize-loops=4 -S -o pr36244.s
...

So we run the test a number of times with effectively the same option set.

The easiest way to fix this would be to rewrite the dg-options -O<x> into a
dg-skip-if.

OTOH, if we're running these with the same option level, maybe we should just
move them out of torture tests.

Reply via email to