diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5c5b9f4b840..161768c7405 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-12-17 Andrew Stubbs + + * config/gcn/gcn-valu.md (extract_last_): New expander. + (fold_extract_last_): New expander. + 2019-12-17 Andrew Stubbs * config/gcn/gcn.h (CLZ_DEFINED_VALUE_AT_ZERO): Define. diff --git a/gcc/config/gcn/gcn-valu.md b/gcc/config/gcn/gcn-valu.md index 42604466161..3b3be8a9e36 100644 --- a/gcc/config/gcn/gcn-valu.md +++ b/gcc/config/gcn/gcn-valu.md @@ -591,6 +591,48 @@ (set_attr "exec" "none") (set_attr "laneselect" "yes")]) +(define_expand "extract_last_" + [(match_operand: 0 "register_operand") + (match_operand:DI 1 "gcn_alu_operand") + (match_operand:VEC_ALLREG_MODE 2 "register_operand")] + "can_create_pseudo_p ()" + { + rtx dst = operands[0]; + rtx mask = operands[1]; + rtx vect = operands[2]; + rtx tmpreg = gen_reg_rtx (SImode); + + emit_insn (gen_clzdi2 (tmpreg, mask)); + emit_insn (gen_subsi3 (tmpreg, GEN_INT (63), tmpreg)); + emit_insn (gen_vec_extract (dst, vect, tmpreg)); + DONE; + }) + +(define_expand "fold_extract_last_" + [(match_operand: 0 "register_operand") + (match_operand: 1 "gcn_alu_operand") + (match_operand:DI 2 "gcn_alu_operand") + (match_operand:VEC_ALLREG_MODE 3 "register_operand")] + "can_create_pseudo_p ()" + { + rtx dst = operands[0]; + rtx default_value = operands[1]; + rtx mask = operands[2]; + rtx vect = operands[3]; + rtx else_label = gen_label_rtx (); + rtx end_label = gen_label_rtx (); + + rtx cond = gen_rtx_EQ (VOIDmode, mask, const0_rtx); + emit_jump_insn (gen_cbranchdi4 (cond, mask, const0_rtx, else_label)); + emit_insn (gen_extract_last_ (dst, mask, vect)); + emit_jump_insn (gen_jump (end_label)); + emit_barrier (); + emit_label (else_label); + emit_move_insn (dst, default_value); + emit_label (end_label); + DONE; + }) + (define_expand "vec_init" [(match_operand:VEC_ALLREG_MODE 0 "register_operand") (match_operand 1)] diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5fff39ec7fe..28b7400dfd7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-12-17 Andrew Stubbs + + * lib/target-supports.exp + (check_effective_target_vect_fold_extract_last): Add amdgcn. + 2019-12-17 Hongyu Wang * gcc.target/i386/pr92651.c: New testcase. diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 80e9d6720bd..98f1141a8a4 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -6974,7 +6974,8 @@ proc check_effective_target_vect_logical_reduc { } { # Return 1 if the target supports the fold_extract_last optab. proc check_effective_target_vect_fold_extract_last { } { - return [check_effective_target_aarch64_sve] + return [expr { [check_effective_target_aarch64_sve] + || [istarget amdgcn*-*-*] }] } # Return 1 if the target supports section-anchors