]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: generalize ifcombine field-merge tests [PR118025]
authorAlexandre Oliva <oliva@adacore.com>
Fri, 10 Jan 2025 12:32:20 +0000 (09:32 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Fri, 10 Jan 2025 12:32:20 +0000 (09:32 -0300)
A number of tests that check for specific ifcombine transformations
fail on AVR and PRU targets, whose type sizes and alignments aren't
conducive of the expected transformations.  Adjust the expectations.

Most execution tests should run successfully regardless of the
transformations, but a few that could conceivably fail if short and
char have the same bit width now check for that and bypass the tests
that would fail.

Conversely, one test that had such a runtime test, but that would work
regardless, no longer has that runtime test, and its types are
narrowed so that the transformations on 32-bit targets are more likely
to be the same as those that used to take place on 64-bit targets.
This latter change is somewhat obviated by a separate patch, but I've
left it in place anyway.

for  gcc/testsuite/ChangeLog

PR testsuite/118025
* gcc.dg/field-merge-1.c: Skip BIT_FIELD_REF counting on AVR and PRU.
* gcc.dg/field-merge-3.c: Bypass the test if short doesn't have the
expected size.
* gcc.dg/field-merge-8.c: Likewise.
* gcc.dg/field-merge-9.c: Likewise.  Skip optimization counting on
AVR and PRU.
* gcc.dg/field-merge-13.c: Skip optimization counting on AVR and PRU.
* gcc.dg/field-merge-15.c: Likewise.
* gcc.dg/field-merge-17.c: Likewise.
* gcc.dg/field-merge-16.c: Likewise.  Drop runtime bypass.  Use
smaller types.
* gcc.dg/field-merge-14.c: Add comments.

gcc/testsuite/gcc.dg/field-merge-1.c
gcc/testsuite/gcc.dg/field-merge-13.c
gcc/testsuite/gcc.dg/field-merge-14.c
gcc/testsuite/gcc.dg/field-merge-15.c
gcc/testsuite/gcc.dg/field-merge-16.c
gcc/testsuite/gcc.dg/field-merge-17.c
gcc/testsuite/gcc.dg/field-merge-3.c
gcc/testsuite/gcc.dg/field-merge-8.c
gcc/testsuite/gcc.dg/field-merge-9.c

index 1818e104437e1aa90ad06c30c5daf39282ebf47e..4405d40ee79d8773dc6c65d98aa20ef786297254 100644 (file)
@@ -58,7 +58,7 @@ int main () {
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 8 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 8 "optimized" { target { ! { avr-*-* pru-*-* } } } } } */
 /* { dg-final { scan-assembler-not "cmpb" { target { i*86-*-* || x86_64-*-* } } } } */
 /* { dg-final { scan-assembler-times "cmpl" 8 { target { i*86-*-* || x86_64-*-* } } } } */
 /* { dg-final { scan-assembler-times "cmpw" 8 { target { powerpc*-*-* || rs6000-*-* } } } } */
index 7e4f4c499347f63acc6546eae1674dde105ae999..eeef73338f8e5a8dc8aedd2e9676ad8b1d68e6b2 100644 (file)
@@ -90,4 +90,4 @@ int main () {
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "optimizing" 9 "ifcombine" } } */
+/* { dg-final { scan-tree-dump-times "optimizing" 9 "ifcombine" { target { ! { avr-*-* pru-*-* } } } } } */
index 91d84cfebf19648b336e309c846564d020e821c1..73259e0936e4e4aca0af9858b891bf7b1f888bc8 100644 (file)
@@ -1,7 +1,8 @@
 /* { dg-do run } */
 /* { dg-options "-O -fdump-tree-ifcombine-details" } */
 
-/* Check that we don't get confused by multiple conversions.  */
+/* Check that we don't get confused by multiple conversions.  Conceivably, we
+   could combine both tests using b, but the current logic won't do that.  */
 
 __attribute__((noipa))
 int f(int *a,int *d)
index 34641e893c92f25b78ec423386b817f29c0f96e4..fc384645271612fc9e22fbe14186e62fbb64a4e9 100644 (file)
@@ -33,4 +33,4 @@ int main () {
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "optimizing" 6 "ifcombine" } } */
+/* { dg-final { scan-tree-dump-times "optimizing" 6 "ifcombine" { target { ! { avr-*-* pru-*-* } } } } } */
index 2ca23ea663a4518571b0987209a455abf3667c32..afdaf45b6a949953d8da8b47f5068a7968e56ebb 100644 (file)
@@ -4,17 +4,17 @@
 /* Check that tests for sign-extension bits are handled correctly.  */
 
 struct s {
-  short a;
-  short b;
-  unsigned short c;
-  unsigned short d;
-} __attribute__ ((aligned (8)));
+  signed char a;
+  signed char b;
+  unsigned char c;
+  unsigned char d;
+} __attribute__ ((aligned (4)));
 
 struct s p = { -1,  0, 0, 0 };
 struct s q = {  0, -1, 0, 0 };
 struct s r = {  1,  1, 0, 0 };
 
-const long long mask = 1ll << (sizeof (long long) * __CHAR_BIT__ - 5);
+const long mask = 1l << (sizeof (long) * __CHAR_BIT__ - 5);
 
 int fp ()
 {
@@ -50,9 +50,6 @@ int fr ()
 }
 
 int main () {
-  /* Unlikely, but play safe.  */
-  if (sizeof (long long) == sizeof (short))
-    return 0;
   if (fp () < 0
       || fq () < 0
       || fr () > 0)
@@ -63,4 +60,4 @@ int main () {
 /* We test .b after other fields instead of right after .a to give field
    merging a chance, otherwise the masked compares with zero are combined by
    other ifcombine logic.  The .c test is discarded by earlier optimizers.  */
-/* { dg-final { scan-tree-dump-times "optimizing" 6 "ifcombine" } } */
+/* { dg-final { scan-tree-dump-times "optimizing" 6 "ifcombine" { target { ! { avr-*-* pru-*-* } } } } } */
index 06c8ec16e86c654d39d4f6e3dc863f9d520a7699..a42658ac5c51660f1f3c2131d73fb9c8c8df6b32 100644 (file)
@@ -43,4 +43,4 @@ int main () {
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "optimizing" 4 "ifcombine" } } */
+/* { dg-final { scan-tree-dump-times "optimizing" 4 "ifcombine" { target { ! { avr-*-* pru-*-* } } } } } */
index f26e8a96ea04f6f2dd67aeb8cff11b0779d9f50a..a9fe404fa426133b7737c54a2a7d835af7f67f81 100644 (file)
@@ -31,6 +31,8 @@ void f (void) {
 }
 
 int main () {
+  if (sizeof (short) != 2)
+    return 0;
   f ();
   return 0;
 }
index ae270e10070e4e905622ca5a5e64efc31388fc52..7d49c2789013b2d53b16e44d462923c4cf054d58 100644 (file)
@@ -20,6 +20,8 @@ void f (void) {
 }
 
 int main () {
+  if (sizeof (short) != 2)
+    return 0;
   f ();
   return 0;
 }
index 04df54c2b74efece3ecff1e2447a82d0df9527d8..49ef59847ac07c3ee4c398d25b43c4506bfee464 100644 (file)
@@ -29,8 +29,10 @@ void f (void) {
 }
 
 int main () {
+  if (sizeof (short) != 2)
+    return 0;
   f ();
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "optimizing two comparisons" 2 "ifcombine" } } */
+/* { dg-final { scan-tree-dump-times "optimizing two comparisons" 2 "ifcombine" { target { ! { avr-*-* pru-*-* } } } } } */