From a1bfb5b16b4b55ae875d346a7b462a18316ad959 Mon Sep 17 00:00:00 2001 From: Ilya Leoshkevich Date: Tue, 1 Oct 2019 14:04:08 +0000 Subject: [PATCH] S/390: Remove code duplication in vec_* comparison expanders s390.md uses a lot of near-identical expanders that perform dispatching to other expanders based on operand types. Since the following patch would require even more of these, avoid copy-pasting the code by generating these expanders using an iterator. gcc/ChangeLog: 2019-10-01 Ilya Leoshkevich PR target/77918 * config/s390/s390.c (s390_expand_vec_compare): Use gen_vec_cmpordered and gen_vec_cmpunordered. * config/s390/vector.md (vec_cmpuneq, vec_cmpltgt, vec_ordered, vec_unordered): Delete. (vec_ordered): Rename to vec_cmpordered. (vec_unordered): Rename to vec_cmpunordered. (VEC_CMP_EXPAND): New iterator for the generic dispatcher. (vec_cmp): Generic dispatcher. From-SVN: r276409 --- gcc/ChangeLog | 12 +++++++ gcc/config/s390/s390.c | 4 +-- gcc/config/s390/vector.md | 67 +++++++-------------------------------- 3 files changed, 25 insertions(+), 58 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 60c8f9f534c..c32bf846011 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2019-10-01 Ilya Leoshkevich + + PR target/77918 + * config/s390/s390.c (s390_expand_vec_compare): Use + gen_vec_cmpordered and gen_vec_cmpunordered. + * config/s390/vector.md (vec_cmpuneq, vec_cmpltgt, vec_ordered, + vec_unordered): Delete. + (vec_ordered): Rename to vec_cmpordered. + (vec_unordered): Rename to vec_cmpunordered. + (VEC_CMP_EXPAND): New iterator for the generic dispatcher. + (vec_cmp): Generic dispatcher. + 2019-10-01 Ilya Leoshkevich PR target/77918 diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 1764c3450e6..062cbd8099d 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -6523,10 +6523,10 @@ s390_expand_vec_compare (rtx target, enum rtx_code cond, emit_insn (gen_vec_cmpltgt (target, cmp_op1, cmp_op2)); return; case ORDERED: - emit_insn (gen_vec_ordered (target, cmp_op1, cmp_op2)); + emit_insn (gen_vec_cmpordered (target, cmp_op1, cmp_op2)); return; case UNORDERED: - emit_insn (gen_vec_unordered (target, cmp_op1, cmp_op2)); + emit_insn (gen_vec_cmpunordered (target, cmp_op1, cmp_op2)); return; default: break; } diff --git a/gcc/config/s390/vector.md b/gcc/config/s390/vector.md index d624d3f5473..451d07de287 100644 --- a/gcc/config/s390/vector.md +++ b/gcc/config/s390/vector.md @@ -1472,22 +1472,6 @@ operands[3] = gen_reg_rtx (mode); }) -(define_expand "vec_cmpuneq" - [(match_operand 0 "register_operand" "") - (match_operand 1 "register_operand" "") - (match_operand 2 "register_operand" "")] - "TARGET_VX" -{ - if (GET_MODE (operands[1]) == V4SFmode) - emit_insn (gen_vec_cmpuneqv4sf (operands[0], operands[1], operands[2])); - else if (GET_MODE (operands[1]) == V2DFmode) - emit_insn (gen_vec_cmpuneqv2df (operands[0], operands[1], operands[2])); - else - gcc_unreachable (); - - DONE; -}) - ; LTGT a <> b -> a > b | b > a (define_expand "vec_cmpltgt" [(set (match_operand: 0 "register_operand" "=v") @@ -1500,24 +1484,8 @@ operands[3] = gen_reg_rtx (mode); }) -(define_expand "vec_cmpltgt" - [(match_operand 0 "register_operand" "") - (match_operand 1 "register_operand" "") - (match_operand 2 "register_operand" "")] - "TARGET_VX" -{ - if (GET_MODE (operands[1]) == V4SFmode) - emit_insn (gen_vec_cmpltgtv4sf (operands[0], operands[1], operands[2])); - else if (GET_MODE (operands[1]) == V2DFmode) - emit_insn (gen_vec_cmpltgtv2df (operands[0], operands[1], operands[2])); - else - gcc_unreachable (); - - DONE; -}) - ; ORDERED (a, b): a >= b | b > a -(define_expand "vec_ordered" +(define_expand "vec_cmpordered" [(set (match_operand: 0 "register_operand" "=v") (ge: (match_operand:VFT 1 "register_operand" "v") (match_operand:VFT 2 "register_operand" "v"))) @@ -1528,45 +1496,32 @@ operands[3] = gen_reg_rtx (mode); }) -(define_expand "vec_ordered" - [(match_operand 0 "register_operand" "") - (match_operand 1 "register_operand" "") - (match_operand 2 "register_operand" "")] - "TARGET_VX" -{ - if (GET_MODE (operands[1]) == V4SFmode) - emit_insn (gen_vec_orderedv4sf (operands[0], operands[1], operands[2])); - else if (GET_MODE (operands[1]) == V2DFmode) - emit_insn (gen_vec_orderedv2df (operands[0], operands[1], operands[2])); - else - gcc_unreachable (); - - DONE; -}) - ; UNORDERED (a, b): !ORDERED (a, b) -(define_expand "vec_unordered" +(define_expand "vec_cmpunordered" [(match_operand: 0 "register_operand" "=v") (match_operand:VFT 1 "register_operand" "v") (match_operand:VFT 2 "register_operand" "v")] "TARGET_VX" { - emit_insn (gen_vec_ordered (operands[0], operands[1], operands[2])); + emit_insn (gen_vec_cmpordered (operands[0], operands[1], operands[2])); emit_insn (gen_rtx_SET (operands[0], gen_rtx_NOT (mode, operands[0]))); DONE; }) -(define_expand "vec_unordered" +(define_code_iterator VEC_CMP_EXPAND + [uneq ltgt ordered unordered]) + +(define_expand "vec_cmp" [(match_operand 0 "register_operand" "") - (match_operand 1 "register_operand" "") - (match_operand 2 "register_operand" "")] + (VEC_CMP_EXPAND (match_operand 1 "register_operand" "") + (match_operand 2 "register_operand" ""))] "TARGET_VX" { if (GET_MODE (operands[1]) == V4SFmode) - emit_insn (gen_vec_unorderedv4sf (operands[0], operands[1], operands[2])); + emit_insn (gen_vec_cmpv4sf (operands[0], operands[1], operands[2])); else if (GET_MODE (operands[1]) == V2DFmode) - emit_insn (gen_vec_unorderedv2df (operands[0], operands[1], operands[2])); + emit_insn (gen_vec_cmpv2df (operands[0], operands[1], operands[2])); else gcc_unreachable (); -- 2.30.2