]> gcc.gnu.org Git - gcc.git/commitdiff
S/390: Fix PR94666
authorAndreas Krebbel <krebbel@linux.ibm.com>
Mon, 4 May 2020 08:43:02 +0000 (10:43 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 17 Sep 2020 15:40:15 +0000 (17:40 +0200)
The vector popcount expanders use a hardcoded subreg.  This might lead
to double subregs being generated which then fail to match.  With this
patch simplify_gen_subreg is used instead to fold the subregs.

gcc/ChangeLog:

2020-05-04  Andreas Krebbel  <krebbel@linux.ibm.com>

Backport from mainline
2020-04-20  Andreas Krebbel  <krebbel@linux.ibm.com>

* config/s390/vector.md ("popcountv8hi2_vx", "popcountv4si2_vx")
("popcountv2di2_vx"): Use simplify_gen_subreg.

gcc/testsuite/ChangeLog:

2020-05-04  Andreas Krebbel  <krebbel@linux.ibm.com>

Backport from mainline
2020-04-20  Andreas Krebbel  <krebbel@linux.ibm.com>

* g++.dg/pr94666.C: New test.

gcc/ChangeLog
gcc/config/s390/vector.md
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr94666.C [new file with mode: 0644]

index bdc3a9c348bbd5b47bb948f3b607c8dd0638ea8d..5ddecbac106755127108136cfce21ce4765e3816 100644 (file)
@@ -1,3 +1,11 @@
+2020-05-04  Andreas Krebbel  <krebbel@linux.ibm.com>
+
+       Backport from mainline
+       2020-04-20  Andreas Krebbel  <krebbel@linux.ibm.com>
+
+       * config/s390/vector.md ("popcountv8hi2_vx", "popcountv4si2_vx")
+       ("popcountv2di2_vx"): Use simplify_gen_subreg.
+
 2020-05-04  Andreas Krebbel  <krebbel@linux.ibm.com>
 
        Backport from mainline
index f11ca85ad972d27b88db1ea7693d1de44398715c..24b200e0c5709bac0488287b1db774e238a259dd 100644 (file)
 
 (define_expand "popcountv8hi2_vx"
   [(set (match_dup 2)
-       (unspec:V16QI [(subreg:V16QI (match_operand:V8HI 1 "register_operand" "v") 0)]
+       (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")]
                      UNSPEC_POPCNT))
    ; Make a copy of the result
    (set (match_dup 3) (match_dup 2))
 ]
   "TARGET_VX && !TARGET_VXE"
 {
+  operands[1] = simplify_gen_subreg (V16QImode, operands[1],
+                                    V8HImode, 0);
   operands[2] = gen_reg_rtx (V16QImode);
   operands[3] = gen_reg_rtx (V16QImode);
   operands[4] = gen_reg_rtx (V16QImode);
 
 (define_expand "popcountv4si2_vx"
   [(set (match_dup 2)
-       (unspec:V16QI [(subreg:V16QI (match_operand:V4SI 1 "register_operand" "v") 0)]
+       (unspec:V16QI [(match_operand:V4SI 1 "register_operand" "v")]
                      UNSPEC_POPCNT))
    (set (match_operand:V4SI 0 "register_operand" "=v")
        (unspec:V4SI [(match_dup 2) (match_dup 3)]
                     UNSPEC_VEC_VSUM))]
   "TARGET_VX && !TARGET_VXE"
 {
+  operands[1] = simplify_gen_subreg (V16QImode, operands[1], V4SImode, 0);
   operands[2] = gen_reg_rtx (V16QImode);
   operands[3] = force_reg (V16QImode, CONST0_RTX (V16QImode));
 })
 
 (define_expand "popcountv2di2_vx"
   [(set (match_dup 2)
-       (unspec:V16QI [(subreg:V16QI (match_operand:V2DI 1 "register_operand" "v") 0)]
+       (unspec:V16QI [(match_operand:V2DI 1 "register_operand" "v")]
                      UNSPEC_POPCNT))
    (set (match_dup 3)
        (unspec:V4SI [(match_dup 2) (match_dup 4)]
                     UNSPEC_VEC_VSUMG))]
   "TARGET_VX && !TARGET_VXE"
 {
+  operands[1] = simplify_gen_subreg (V16QImode, operands[1], V2DImode, 0);
   operands[2] = gen_reg_rtx (V16QImode);
   operands[3] = gen_reg_rtx (V4SImode);
   operands[4] = force_reg (V16QImode, CONST0_RTX (V16QImode));
index 263e999b6dd85bb60fb754ce17dc8b0e75d38d11..0529cc27354e724729fbbbd613568a22c4656c0c 100644 (file)
@@ -1,3 +1,10 @@
+2020-05-04  Andreas Krebbel  <krebbel@linux.ibm.com>
+
+       Backport from mainline
+       2020-04-20  Andreas Krebbel  <krebbel@linux.ibm.com>
+
+       * g++.dg/pr94666.C: New test.
+
 2020-05-04  Andreas Krebbel  <krebbel@linux.ibm.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/g++.dg/pr94666.C b/gcc/testsuite/g++.dg/pr94666.C
new file mode 100644 (file)
index 0000000..a9bfb24
--- /dev/null
@@ -0,0 +1,20 @@
+// { dg-do compile }
+// { dg-options "-O3" }
+// { dg-additional-options "-march=z13" { target s390*-*-* } }
+
+int a, c;
+struct A {
+  int e() {
+    int f;
+    for (int b = 0; b < 4; b++) {
+      a = __builtin_popcountl(d[b]);
+      f += a;
+    }
+    return f;
+  }
+  long d[4];
+} * g;
+void h() {
+  for (int b; b; b++)
+    c += g[b].e();
+}
This page took 0.098637 seconds and 5 git commands to generate.