From f0c6475aeaa426c110cdc4df6c63c0ee63e5776e Mon Sep 17 00:00:00 2001 From: Bernd Schmidt <bernds@gcc.gnu.org> Date: Fri, 16 Apr 2010 10:04:15 +0000 Subject: [PATCH] re PR target/40603 (unnecessary conversion from unsigned byte load to signed byte load) PR target/40603 * config/arm/arm.md (cbranchqi4): New pattern. * config/arm/predicates.md (const0_operand, cbranchqi4_comparison_operator): New predicates. PR target/40603 * gcc.target/arm/thumb-cbranchqi.c: New test. From-SVN: r158407 --- gcc/ChangeLog | 19 ++++++++++----- gcc/config/arm/arm.md | 24 +++++++++++++++++++ gcc/config/arm/predicates.md | 7 ++++++ gcc/testsuite/ChangeLog | 11 +++++---- .../gcc.target/arm/thumb-cbranchqi.c | 15 ++++++++++++ 5 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gcc.target/arm/thumb-cbranchqi.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bca40b741b59..38952fc0aa01 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,9 +1,16 @@ +2010-04-16 Bernd Schmidt <bernds@codesourcery.com> + + PR target/40603 + * config/arm/arm.md (cbranchqi4): New pattern. + * config/arm/predicates.md (const0_operand, + cbranchqi4_comparison_operator): New predicates. + 2010-04-16 Richard Guenther <rguenther@suse.de> * gimple-pretty-print.c (dump_gimple_phi): Dump alias info. (dump_gimple_stmt): Likewise. -2010-04-16 Bernd Schmidt <bernd.schmidt@codesourcery.com> +2010-04-16 Bernd Schmidt <bernds@codesourcery.com> * recog.h (struct recog_data): New field is_operator. (struct insn_operand_data): New field is_operator. @@ -178,7 +185,7 @@ div_and_round_double): Move prototypes ... * double-int.h: ... here. -2010-04-15 Bernd Schmidt <bernd.schmidt@codesourcery.com> +2010-04-15 Bernd Schmidt <bernds@codesourcery.com> PR target/43742 * config/sh/sh.md (doloop_end_split, dect): Undo previous patch. Use @@ -206,7 +213,7 @@ comment. * expmed.c (mask_rtx, lshift_value): (Ditto.). -2010-04-14 Bernd Schmidt <bernd.schmidt@codesourcery.com> +2010-04-14 Bernd Schmidt <bernds@codesourcery.com> PR target/21803 * ifcvt.c (cond_exec_process_if_block): Look for identical sequences @@ -790,7 +797,7 @@ (arm_output_addr_const_extra): Output expression for new pattern. * config/arm/arm.md (UNSPEC_SYMBOL_OFFSET): New unspec symbol. -2010-04-10 Bernd Schmidt <bernd.schmidt@codesourcery.com> +2010-04-10 Bernd Schmidt <bernds@codesourcery.com> * ira-costs.c (record_reg_classes): Ignore alternatives that are not enabled. @@ -820,7 +827,7 @@ * ipa-prop.c (ipa_print_node_jump_functions): Likewise. 2010-04-09 Eric Botcazou <ebotcazou@adacore.com> - Bernd Schmidt <bernd.schmidt@codesourcery.com> + Bernd Schmidt <bernds@codesourcery.com> * loop-invariant.c (replace_uses): New static function. (move_invariant_reg): Use it to ensure we can replace the uses. @@ -2354,7 +2361,7 @@ * c-decl.c (grokparms): Set arg_types to NULL_TREE if there was an error. -2010-03-19 Bernd Schmidt <bernd.schmidt@codesourcery.com> +2010-03-19 Bernd Schmidt <bernds@codesourcery.com> PR rtl-optimization/42258 * ira-lives.c (check_and_make_def_conflict): Ignore conflict for a diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 4604e139898b..fb9c02429d55 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -6668,6 +6668,30 @@ operands[2] = force_reg (SImode, operands[2]); ") +;; A pattern to recognize a special situation and optimize for it. +;; On the thumb, zero-extension from memory is preferrable to sign-extension +;; due to the available addressing modes. Hence, convert a signed comparison +;; with zero into an unsigned comparison with 127 if possible. +(define_expand "cbranchqi4" + [(set (pc) (if_then_else + (match_operator 0 "lt_ge_comparison_operator" + [(match_operand:QI 1 "memory_operand" "") + (match_operand:QI 2 "const0_operand" "")]) + (label_ref (match_operand 3 "" "")) + (pc)))] + "TARGET_THUMB1" +{ + rtx xops[3]; + xops[1] = gen_reg_rtx (SImode); + emit_insn (gen_zero_extendqisi2 (xops[1], operands[1])); + xops[2] = GEN_INT (127); + xops[0] = gen_rtx_fmt_ee (GET_CODE (operands[0]) == GE ? LEU : GTU, + VOIDmode, xops[1], xops[2]); + xops[3] = operands[3]; + emit_insn (gen_cbranchsi4 (xops[0], xops[1], xops[2], xops[3])); + DONE; +}) + (define_expand "cbranchsf4" [(set (pc) (if_then_else (match_operator 0 "arm_comparison_operator" diff --git a/gcc/config/arm/predicates.md b/gcc/config/arm/predicates.md index d351f443851d..a60da9a32717 100644 --- a/gcc/config/arm/predicates.md +++ b/gcc/config/arm/predicates.md @@ -94,6 +94,10 @@ (and (match_code "const_int") (match_test "const_ok_for_arm (~INTVAL (op))"))) +(define_predicate "const0_operand" + (and (match_code "const_int") + (match_test "INTVAL (op) == 0"))) + ;; Something valid on the RHS of an ARM data-processing instruction (define_predicate "arm_rhs_operand" (ior (match_operand 0 "s_register_operand") @@ -203,6 +207,9 @@ && (TARGET_FPA || TARGET_VFP)") (match_code "unordered,ordered,unlt,unle,unge,ungt")))) +(define_special_predicate "lt_ge_comparison_operator" + (match_code "lt,ge")) + (define_special_predicate "minmax_operator" (and (match_code "smin,smax,umin,umax") (match_test "mode == GET_MODE (op)"))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3f0fe2beab27..450aa4f0e440 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,7 +1,10 @@ -2010-04-16 Bernd Schmidt <bernd.schmidt@codesourcery.com> +2010-04-16 Bernd Schmidt <bernds@codesourcery.com> PR target/41514 - gcc.target/arm/thumb-comparisons.c: New test. + * gcc.target/arm/thumb-comparisons.c: New test. + + PR target/40603 + * gcc.target/arm/thumb-cbranchqi.c: New test. 2010-04-16 Christian Bruel <christian.bruel@st.com> @@ -30,7 +33,7 @@ * gcc.dg/torture/ipa-pta-2.c: Likewise. * gcc.dg/torture/ipa-pta-1.c: Adjust. -2010-04-14 Bernd Schmidt <bernd.schmidt@codesourcery.com> +2010-04-14 Bernd Schmidt <bernds@codesourcery.com> PR target/21803 * gcc.target/arm/pr42496.c: New test. @@ -1217,7 +1220,7 @@ * gcc.dg/pr43211.c: New test. * gcc.dg/pr18809-1.c: Don't expect an error when calling foo. -2010-03-19 Bernd Schmidt <bernd.schmidt@codesourcery.com> +2010-03-19 Bernd Schmidt <bernds@codesourcery.com> PR rtl-optimization/42258 * gcc.target/arm/thumb1-mul-moves.c: New test. diff --git a/gcc/testsuite/gcc.target/arm/thumb-cbranchqi.c b/gcc/testsuite/gcc.target/arm/thumb-cbranchqi.c new file mode 100644 index 000000000000..ad28e7f54b8f --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/thumb-cbranchqi.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-mthumb -Os" } */ +/* { dg-require-effective-target arm_thumb1_ok } */ + +int ldrb(unsigned char* p) +{ + if (p[8] <= 0x7F) + return 2; + else + return 5; +} + + +/* { dg-final { scan-assembler "127" } } */ +/* { dg-final { scan-assembler "bhi" } } */ -- GitLab