From: Alan Modra Date: Sat, 14 Jan 2017 13:24:46 +0000 (+1030) Subject: Avoid PR72749 by not using unspecs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d6b251481d16865e3ebb4e6075f99c2c484e4c72;p=gcc.git Avoid PR72749 by not using unspecs Rather than using unspecs in doloop insns to stop combine creating these insns, use legitimate_combined_insn. PR target/72749 * combine.c (recog_for_combine_1): Set INSN_CODE before calling target legitimate_combined_insn. * config/rs6000/rs6000.c (TARGET_LEGITIMATE_COMBINED_INSN): Define. (rs6000_legitimate_combined_insn): New function. * config/rs6000/rs6000.md (UNSPEC_DOLOOP): Delete, and remove all uses. (ctr_internal3): Rename from *ctr_internal5. (ctr_internal4): Rename from *ctr_internal6. (ctr_internal1, ctr_internal2): Remove '*' from name. From-SVN: r244465 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e0f5d7a2360..910605368d3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,7 +1,20 @@ +2017-01-14 Alan Modra + + PR target/72749 + * combine.c (recog_for_combine_1): Set INSN_CODE before calling + target legitimate_combined_insn. + * config/rs6000/rs6000.c (TARGET_LEGITIMATE_COMBINED_INSN): Define. + (rs6000_legitimate_combined_insn): New function. + * config/rs6000/rs6000.md (UNSPEC_DOLOOP): Delete, and remove + all uses. + (ctr_internal3): Rename from *ctr_internal5. + (ctr_internal4): Rename from *ctr_internal6. + (ctr_internal1, ctr_internal2): Remove '*' from name. + 2017-01-14 Gerald Pfeifer * doc/frontends.texi (G++ and GCC): Remove references to Java. - + 2017-01-13 Jeff Law PR tree-optimization/33562 @@ -362,7 +375,7 @@ * config.gcc (*-*-fuchsia*): Set native_system_header_dir. (aarch64*-*-fuchsia*, arm*-*-fuchsia*, x86_64-*-fuchsia*): Add to targets. - * config.host: (aarch64*-*-fuchsia*, arm*-*-fuchsia*): Add to hosts. + * config.host: (aarch64*-*-fuchsia*, arm*-*-fuchsia*): Add to hosts. 2016-01-10 Richard Biener diff --git a/gcc/combine.c b/gcc/combine.c index 3598045afdb..28133ff3ba9 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -11201,6 +11201,7 @@ recog_for_combine_1 (rtx *pnewpat, rtx_insn *insn, rtx *pnotes) old_icode = INSN_CODE (insn); PATTERN (insn) = pat; REG_NOTES (insn) = notes; + INSN_CODE (insn) = insn_code_number; /* Allow targets to reject combined insn. */ if (!targetm.legitimate_combined_insn (insn)) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 5909e27a6e2..11394b2f700 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -1558,6 +1558,9 @@ static const struct attribute_spec rs6000_attribute_table[] = #undef TARGET_CONST_NOT_OK_FOR_DEBUG_P #define TARGET_CONST_NOT_OK_FOR_DEBUG_P rs6000_const_not_ok_for_debug_p +#undef TARGET_LEGITIMATE_COMBINED_INSN +#define TARGET_LEGITIMATE_COMBINED_INSN rs6000_legitimate_combined_insn + #undef TARGET_ASM_FUNCTION_PROLOGUE #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue #undef TARGET_ASM_FUNCTION_EPILOGUE @@ -9076,6 +9079,49 @@ rs6000_const_not_ok_for_debug_p (rtx x) return false; } + +/* Implement the TARGET_LEGITIMATE_COMBINED_INSN hook. */ + +static bool +rs6000_legitimate_combined_insn (rtx_insn *insn) +{ + switch (INSN_CODE (insn)) + { + /* Reject creating doloop insns. Combine should not be allowed + to create these for a number of reasons: + 1) In a nested loop, if combine creates one of these in an + outer loop and the register allocator happens to allocate ctr + to the outer loop insn, then the inner loop can't use ctr. + Inner loops ought to be more highly optimized. + 2) Combine often wants to create one of these from what was + originally a three insn sequence, first combining the three + insns to two, then to ctrsi/ctrdi. When ctrsi/ctrdi is not + allocated ctr, the splitter takes use back to the three insn + sequence. It's better to stop combine at the two insn + sequence. + 3) Faced with not being able to allocate ctr for ctrsi/crtdi + insns, the register allocator sometimes uses floating point + or vector registers for the pseudo. Since ctrsi/ctrdi is a + jump insn and output reloads are not implemented for jumps, + the ctrsi/ctrdi splitters need to handle all possible cases. + That's a pain, and it gets to be seriously difficult when a + splitter that runs after reload needs memory to transfer from + a gpr to fpr. See PR70098 and PR71763 which are not fixed + for the difficult case. It's better to not create problems + in the first place. */ + case CODE_FOR_ctrsi_internal1: + case CODE_FOR_ctrdi_internal1: + case CODE_FOR_ctrsi_internal2: + case CODE_FOR_ctrdi_internal2: + case CODE_FOR_ctrsi_internal3: + case CODE_FOR_ctrdi_internal3: + case CODE_FOR_ctrsi_internal4: + case CODE_FOR_ctrdi_internal4: + return false; + } + return true; +} + /* Construct the SYMBOL_REF for the tls_get_addr function. */ static GTY(()) rtx rs6000_tls_symbol; diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index a094b92a96e..b3334749860 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -149,7 +149,6 @@ UNSPEC_IEEE128_MOVE UNSPEC_IEEE128_CONVERT UNSPEC_SIGNBIT - UNSPEC_DOLOOP UNSPEC_SF_FROM_SI UNSPEC_SI_FROM_SF ]) @@ -12737,7 +12736,6 @@ (set (match_dup 0) (plus:P (match_dup 0) (const_int -1))) - (unspec [(const_int 0)] UNSPEC_DOLOOP) (clobber (match_scratch:CC 2 "")) (clobber (match_scratch:P 3 ""))])] "" @@ -12748,9 +12746,10 @@ ;; JUMP_INSNs. ;; For the length attribute to be calculated correctly, the ;; label MUST be operand 0. -;; The UNSPEC is present to prevent combine creating this pattern. +;; rs6000_legitimate_combined_insn prevents combine creating any of +;; the ctr insns. -(define_insn "*ctr_internal1" +(define_insn "ctr_internal1" [(set (pc) (if_then_else (ne (match_operand:P 1 "register_operand" "c,*b,*b,*b") (const_int 1)) @@ -12759,7 +12758,6 @@ (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*d*wi*c*l") (plus:P (match_dup 1) (const_int -1))) - (unspec [(const_int 0)] UNSPEC_DOLOOP) (clobber (match_scratch:CC 3 "=X,&x,&x,&x")) (clobber (match_scratch:P 4 "=X,X,&r,r"))] "" @@ -12775,7 +12773,7 @@ [(set_attr "type" "branch") (set_attr "length" "*,16,20,20")]) -(define_insn "*ctr_internal2" +(define_insn "ctr_internal2" [(set (pc) (if_then_else (ne (match_operand:P 1 "register_operand" "c,*b,*b,*b") (const_int 1)) @@ -12784,7 +12782,6 @@ (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*d*wi*c*l") (plus:P (match_dup 1) (const_int -1))) - (unspec [(const_int 0)] UNSPEC_DOLOOP) (clobber (match_scratch:CC 3 "=X,&x,&x,&x")) (clobber (match_scratch:P 4 "=X,X,&r,r"))] "" @@ -12802,7 +12799,7 @@ ;; Similar but use EQ -(define_insn "*ctr_internal5" +(define_insn "ctr_internal3" [(set (pc) (if_then_else (eq (match_operand:P 1 "register_operand" "c,*b,*b,*b") (const_int 1)) @@ -12811,7 +12808,6 @@ (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*d*wi*c*l") (plus:P (match_dup 1) (const_int -1))) - (unspec [(const_int 0)] UNSPEC_DOLOOP) (clobber (match_scratch:CC 3 "=X,&x,&x,&x")) (clobber (match_scratch:P 4 "=X,X,&r,r"))] "" @@ -12827,7 +12823,7 @@ [(set_attr "type" "branch") (set_attr "length" "*,16,20,20")]) -(define_insn "*ctr_internal6" +(define_insn "ctr_internal4" [(set (pc) (if_then_else (eq (match_operand:P 1 "register_operand" "c,*b,*b,*b") (const_int 1)) @@ -12836,7 +12832,6 @@ (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*d*wi*c*l") (plus:P (match_dup 1) (const_int -1))) - (unspec [(const_int 0)] UNSPEC_DOLOOP) (clobber (match_scratch:CC 3 "=X,&x,&x,&x")) (clobber (match_scratch:P 4 "=X,X,&r,r"))] "" @@ -12863,7 +12858,6 @@ (match_operand 6 "" ""))) (set (match_operand:P 0 "int_reg_operand" "") (plus:P (match_dup 1) (const_int -1))) - (unspec [(const_int 0)] UNSPEC_DOLOOP) (clobber (match_scratch:CC 3 "")) (clobber (match_scratch:P 4 ""))] "reload_completed" @@ -12889,7 +12883,6 @@ (match_operand 6 "" ""))) (set (match_operand:P 0 "nonimmediate_operand" "") (plus:P (match_dup 1) (const_int -1))) - (unspec [(const_int 0)] UNSPEC_DOLOOP) (clobber (match_scratch:CC 3 "")) (clobber (match_scratch:P 4 ""))] "reload_completed && ! gpc_reg_operand (operands[0], SImode)"