From 971ea67cc0cb151f951a4b17e48b1cb0b31523f2 Mon Sep 17 00:00:00 2001 From: Xinliang David Li Date: Wed, 10 Sep 2014 20:10:25 +0000 Subject: [PATCH] Fix PR target/63209. From-SVN: r215136 --- gcc/ChangeLog | 6 +++++ gcc/config/arm/arm.md | 10 +++++-- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.c-torture/execute/pr63209.c | 27 +++++++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr63209.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3aaeb0d3f3c..6e532f8c057 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-09-10 Xinliang David Li + + PR target/63209 + * config/arm/arm.md (movcond_addsi): Handle case where source + and target operands are the same. + 2014-09-10 David Malcolm * final.c (this_is_asm_operands): Strengthen this variable from diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 53235749098..e691562ac75 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -9328,10 +9328,16 @@ enum machine_mode mode = SELECT_CC_MODE (GET_CODE (operands[5]), operands[3], operands[4]); enum rtx_code rc = GET_CODE (operands[5]); - operands[6] = gen_rtx_REG (mode, CC_REGNUM); gcc_assert (!(mode == CCFPmode || mode == CCFPEmode)); - rc = reverse_condition (rc); + if (REGNO (operands[2]) != REGNO (operands[0])) + rc = reverse_condition (rc); + else + { + rtx tmp = operands[1]; + operands[1] = operands[2]; + operands[2] = tmp; + } operands[6] = gen_rtx_fmt_ee (rc, VOIDmode, operands[6], const0_rtx); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c9dfcb1d9c8..197297a7543 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-09-10 Xinliang David Li + + PR target/63209 + * gcc.c-torture/execute/pr63209.c: New test. + 2014-09-10 Jakub Jelinek * gcc.target/i386/i386.exp: Only run vect-args.c tests diff --git a/gcc/testsuite/gcc.c-torture/execute/pr63209.c b/gcc/testsuite/gcc.c-torture/execute/pr63209.c new file mode 100644 index 00000000000..9bcb5874563 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr63209.c @@ -0,0 +1,27 @@ +static int Sub(int a, int b) { + return b -a; +} + +static unsigned Select(unsigned a, unsigned b, unsigned c) { + const int pa_minus_pb = + Sub((a >> 8) & 0xff, (b >> 8) & 0xff) + + Sub((a >> 0) & 0xff, (b >> 0) & 0xff); + return (pa_minus_pb <= 0) ? a : b; +} + +__attribute__((noinline)) unsigned Predictor(unsigned left, const unsigned* const top) { + const unsigned pred = Select(top[1], left, top[0]); + return pred; +} + +int main(void) { + const unsigned top[2] = {0xff7a7a7a, 0xff7a7a7a}; + const unsigned left = 0xff7b7b7b; + const unsigned pred = Predictor(left, top /*+ 1*/); + if (pred == left) + return 0; + return 1; +} + + + -- 2.30.2