[Bug target/93533] [10 Regression] ICE due to popcounthi2 expansion with -march=z196 since r10-3720

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Feb 1 12:43:00 GMT 2020


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2020-02-01
                 CC|                            |krebbel at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
   Target Milestone|---                         |10.0
     Ever confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index 2959d8c0f17..e37ba49444a 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -11670,21 +11670,28 @@ (define_expand "popcountsi2"
 })

 (define_expand "popcounthi2_z196"
-  [; popcnt op0, op1
-   (parallel [(set (match_operand:HI 0 "register_operand" "")
+  [; popcnt op2, op1
+   (parallel [(set (match_dup 2)
                   (unspec:HI [(match_operand:HI 1 "register_operand")]
                              UNSPEC_POPCNT))
              (clobber (reg:CC CC_REGNUM))])
-   ; sllk op2, op0, 8
-   (set (match_dup 2)
-       (ashift:SI (match_dup 0) (const_int 8)))
-   ; ar op0, op2
-   (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
+   ; lr op3, op2
+   (set (match_dup 3) (subreg:SI (match_dup 2) 0))
+   ; srl op4, op3, 8
+   (set (match_dup 4) (lshiftrt:SI (match_dup 3) (const_int 8)))
+   ; ar op3, op4
+   (parallel [(set (match_dup 3) (plus:SI (match_dup 3) (match_dup 4)))
              (clobber (reg:CC CC_REGNUM))])
-   ; srl op0, op0, 8
-   (set (match_dup 0) (lshiftrt:HI (match_dup 0) (const_int 8)))]
+   ; llgc op0, op3
+   (parallel [(set (match_operand:HI 0 "register_operand" "")
+                  (and:HI (subreg:HI (match_dup 3) 2) (const_int 255)))
+             (clobber (reg:CC CC_REGNUM))])]
   "TARGET_Z196"
-  "operands[2] = gen_reg_rtx (SImode);")
+{
+  operands[2] = gen_reg_rtx (HImode);
+  operands[3] = gen_reg_rtx (SImode);
+  operands[4] = gen_reg_rtx (SImode);
+})

 (define_expand "popcounthi2"
   [(set (match_dup 2)

seems to work for me.


More information about the Gcc-bugs mailing list