[PATCH] Adjust testcase for O2 vectorization.

Kewen.Lin linkw@linux.ibm.com
Fri Oct 15 07:11:20 GMT 2021


on 2021/10/14 下午6:56, Kewen.Lin via Gcc-patches wrote:
> Hi Hongtao,
> 
> on 2021/10/14 下午3:11, liuhongt wrote:
>> Hi Kewen:
>>   Cound you help to verify if this patch fix those regressions
>> for rs6000 port.
>>
> 
> The ppc64le run just finished, there are still some regresssions:
> 
> NA->XPASS: c-c++-common/Wstringop-overflow-2.c  -Wc++-compat   (test for warnings, line 194)
> NA->XPASS: c-c++-common/Wstringop-overflow-2.c  -Wc++-compat   (test for warnings, line 212)
> NA->XPASS: c-c++-common/Wstringop-overflow-2.c  -Wc++-compat   (test for warnings, line 296)
> NA->XPASS: c-c++-common/Wstringop-overflow-2.c  -Wc++-compat   (test for warnings, line 314)
> NA->FAIL: gcc.dg/Wstringop-overflow-21-novec.c (test for excess errors)
> NA->FAIL: gcc.dg/Wstringop-overflow-21-novec.c  (test for warnings, line 18)
> NA->FAIL: gcc.dg/Wstringop-overflow-21-novec.c  (test for warnings, line 29)
> NA->FAIL: gcc.dg/Wstringop-overflow-21-novec.c  (test for warnings, line 45)
> NA->FAIL: gcc.dg/Wstringop-overflow-21-novec.c  (test for warnings, line 55)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c note (test for warnings, line 104)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c note (test for warnings, line 137)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c note (test for warnings, line 19)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c note (test for warnings, line 39)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c note (test for warnings, line 56)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c note (test for warnings, line 70)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c (test for excess errors)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c  (test for warnings, line 116)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c  (test for warnings, line 131)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c  (test for warnings, line 146)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c  (test for warnings, line 33)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c  (test for warnings, line 50)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c  (test for warnings, line 64)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c  (test for warnings, line 78)
> NA->FAIL: gcc.dg/Wstringop-overflow-76-novec.c  (test for warnings, line 97)
> PASS->FAIL: c-c++-common/Wstringop-overflow-2.c  -std=gnu++14 (test for excess errors)
> NA->FAIL: c-c++-common/Wstringop-overflow-2.c  -std=gnu++14  (test for warnings, line 229)
> NA->FAIL: c-c++-common/Wstringop-overflow-2.c  -std=gnu++14  (test for warnings, line 230)
> NA->FAIL: c-c++-common/Wstringop-overflow-2.c  -std=gnu++14  (test for warnings, line 331)
> NA->FAIL: c-c++-common/Wstringop-overflow-2.c  -std=gnu++14  (test for warnings, line 332)
> // omitting -std=gnu++17, -std=gnu++2a, -std=gnu++98
> 
> I'll have a look and get back to you tomorrow.
> 

The failure c-c++-common/Wstringop-overflow-2.c is due to that the
current proc check_vect_slp_vnqihi_store_usage is made as "cache"
but it can vary for different input patterns.  For rs6000 the test
for v2qi fails, the cached test result makes v4qi check fail
unexpectedly (should pass).  I adjusted caching for the following users
check_effective_target_vect_slp_v*_store, also refactored a bit.
One trivial change is to add one new argument macro then we can just
compile the corresponding foo* function instead of all, hope it helps
to make the debugging outputs compact.

For the failure Wstringop-overflow-76-novec.c, there is one typo
comparing to the original Wstringop-overflow-76.c.  Guess it failed
on x86 too?  It would be surprising if it passes on x86.
As to the failure Wstringop-overflow-21-novec.c, I confirmed it's
just noise, patching typos caused this failure.

One new round ppc64le testing just finished with below diff and all
previous regressions are fixed without any new regressions.


diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-76-novec.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-76-novec.c
index d000b587a65..1132348c5f4 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-76-novec.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-76-novec.c
@@ -82,7 +82,7 @@ void max_d8_p (char *q, int i)
 struct A3_5
 {
   char a3[3];  // { dg-message "at offset 3 into destination object 'a3' of size 3" "pr??????" { xfail *-*-* } }
-  char a5[5];
+  char a5[5];  // { dg-message "at offset 5 into destination object 'a5' of size 5" "note" }
 };

 void max_A3_A5 (int i, struct A3_5 *pa3_5)
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 530c5769614..8736b908ec7 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -7584,12 +7584,13 @@ proc check_effective_target_vect_element_align_preferred { } {
 # Return zero if the desirable pattern isn't found.
 # It's used by Warray-bounds/Wstringop-overflow testcases which are
 # regressed by O2 vectorization, refer to PR102697/PR102462/PR102706
-proc check_vect_slp_vnqihi_store_usage { pattern } {
+proc check_vect_slp_vnqihi_store_usage { pattern macro } {
     global tool

-    return [check_cached_effective_target slp_vnqihi_store_usage {
-      set result [check_compile slp_vnqihi_store_usage assembly {
+    set result [check_compile slp_vnqihi_store_usage assembly {
 	  char a[16] __attribute__ ((aligned (16)));
+	  short b[4] __attribute__((aligned(8)));
+	  #ifdef TEST_V8QI
 	  void
 	  foo ()
 	  {
@@ -7602,7 +7603,7 @@ proc check_vect_slp_vnqihi_store_usage { pattern } {
 	      a[6] = 6;
 	      a[7] = 7;
 	  }
-
+	  #elif TEST_V16QI
 	  void
 	  foo1 ()
 	  {
@@ -7623,7 +7624,7 @@ proc check_vect_slp_vnqihi_store_usage { pattern } {
 	      a[14] = 14;
 	      a[15] = 15;
 	  }
-
+	  #elif TEST_V4QI
 	  void
 	  foo2 ()
 	  {
@@ -7632,22 +7633,21 @@ proc check_vect_slp_vnqihi_store_usage { pattern } {
 	      a[2] = 2;
 	      a[3] = 3;
 	  }
-
+	  #elif TEST_V2QI
 	  void
 	  foo3 ()
 	  {
 	      a[0] = 0;
 	      a[1] = 1;
 	  }
-
-	  short b[4] __attribute__((aligned(8)));
+	  #elif TEST_V2HI
 	  void
 	  foo4 ()
 	  {
 	      b[0] = 0;
 	      b[1] = 1;
 	  }
-
+	  #elif TEST_V4HI
 	  void
 	  foo5 ()
 	  {
@@ -7656,57 +7656,69 @@ proc check_vect_slp_vnqihi_store_usage { pattern } {
 	      b[2] = 2;
 	      b[3] = 3;
 	  }
+	  #endif

-      } "-O2 -fopt-info-all" ]
+      } "-O2 -fopt-info-all -D$macro" ]

       # Get compiler emitted messages and delete generated file.
       set lines [lindex $result 0]
       set output [lindex $result 1]
       remote_file build delete $output

-      # Capture the vectorized info of v2qi, set it to zero if not found.
-	if { ![regexp $pattern $lines whole val] } then {
-	  set val 0
+      # Check pattern exits in lines, set it to zero if not found.
+      if { [regexp $pattern $lines] } then {
+	 return 1
       }

-      return $val
-    }]
+      return 0
 }

 # Return the true if target support vectorization of v2qi store.
 proc check_effective_target_vect_slp_v2qi_store { } {
     set pattern {add new stmt: MEM <vector\(2\) char>}
-    return [expr { [check_vect_slp_vnqihi_store_usage $pattern ] != 0 }]
+    set macro "TEST_V2QI"
+    return [check_cached_effective_target vect_slp_v2qi_store {
+	    expr [check_vect_slp_vnqihi_store_usage $pattern $macro] }]
 }

 # Return the true if target support vectorization of v4qi store.
 proc check_effective_target_vect_slp_v4qi_store { } {
     set pattern {add new stmt: MEM <vector\(4\) char>}
-    return [expr { [check_vect_slp_vnqihi_store_usage $pattern ] != 0 }]
+    set macro "TEST_V4QI"
+    return [check_cached_effective_target vect_slp_v4qi_store {
+	    expr [check_vect_slp_vnqihi_store_usage $pattern $macro ] }]
 }

-# Return the true if target support vectorization of v2qi store.
+# Return the true if target support vectorization of v8qi store.
 proc check_effective_target_vect_slp_v8qi_store { } {
     set pattern {add new stmt: MEM <vector\(8\) char>}
-    return [expr { [check_vect_slp_vnqihi_store_usage $pattern ] != 0 }]
+    set macro "TEST_V8QI"
+    return [check_cached_effective_target_vect_slp_v8qi_store {
+	    expr [check_vect_slp_vnqihi_store_usage $pattern $macro ] }]
 }

-# Return the true if target support vectorization of v4qi store.
+# Return the true if target support vectorization of v16qi store.
 proc check_effective_target_vect_slp_v16qi_store { } {
     set pattern {add new stmt: MEM <vector\(16\) char>}
-    return [expr { [check_vect_slp_vnqihi_store_usage $pattern ] != 0 }]
+    set macro "TEST_V16QI"
+    return [check_cached_effective_target_vect_slp_v16qi_store {
+	    expr [check_vect_slp_vnqihi_store_usage $pattern $macro ] }]
 }

 # Return the true if target support vectorization of v2hi store.
 proc check_effective_target_vect_slp_v2hi_store { } {
     set pattern {add new stmt: MEM <vector\(2\) short int>}
-    return [expr { [check_vect_slp_vnqihi_store_usage $pattern ] != 0 }]
+    set macro "TEST_V2HI"
+    return [check_cached_effective_target_vect_slp_v2hi_store {
+	    expr [check_vect_slp_vnqihi_store_usage $pattern $macro ] }]
 }

-# Return the true if target support vectorization of v2hi store.
+# Return the true if target support vectorization of v4hi store.
 proc check_effective_target_vect_slp_v4hi_store { } {
     set pattern {add new stmt: MEM <vector\(4\) short int>}
-    return [expr { [check_vect_slp_vnqihi_store_usage $pattern ] != 0 }]
+    set macro "TEST_V4HI"
+    return [check_cached_effective_target_vect_slp_v4hi_store {
+	    expr [check_vect_slp_vnqihi_store_usage $pattern $macro ] }]
 }



BR,
Kewen


More information about the Gcc-patches mailing list