From 154516d9d2011112deeb5becd98819d63397b2b1 Mon Sep 17 00:00:00 2001 From: Wei Guozhi Date: Fri, 29 Jul 2011 01:27:29 +0000 Subject: [PATCH] re PR rtl-optimization/49799 (gcc arm generates illegal sbfx instruction) PR rtl-optimization/49799 * combine.c (make_compound_operation): Check if the bit field is valid before change it to bit field extraction. * gcc.dg/pr49799.c: New test case. From-SVN: r176911 --- gcc/ChangeLog | 6 ++++++ gcc/combine.c | 1 + gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr49799.c | 25 +++++++++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr49799.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c304e8245b6..0b70415acad 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-07-29 Wei Guozhi + + PR rtl-optimization/49799 + * combine.c (make_compound_operation): Check if the bit field is valid + before change it to bit field extraction. + 2011-07-29 Bernd Schmidt PR rtl-optimization/49891 diff --git a/gcc/combine.c b/gcc/combine.c index 4dbf022fd1b..b5cf245f761 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -7787,6 +7787,7 @@ make_compound_operation (rtx x, enum rtx_code in_code) && GET_CODE (lhs) == ASHIFT && CONST_INT_P (XEXP (lhs, 1)) && INTVAL (rhs) >= INTVAL (XEXP (lhs, 1)) + && INTVAL (XEXP (lhs, 1)) >= 0 && INTVAL (rhs) < mode_width) { new_rtx = make_compound_operation (XEXP (lhs, 0), next_code); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 85daf9f7092..d5e61cb5e8b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-07-29 Wei Guozhi + + PR rtl-optimization/49799 + * gcc.dg/pr49799.c: New test case. + 2011-07-22 Sebastian Pop PR middle-end/48648 diff --git a/gcc/testsuite/gcc.dg/pr49799.c b/gcc/testsuite/gcc.dg/pr49799.c new file mode 100644 index 00000000000..61ac261be51 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr49799.c @@ -0,0 +1,25 @@ +/* PR rtl-optimization/49799 */ +/* { dg-do assemble } */ +/* { dg-options "-O2 -w" } */ + +static __inline int bar(int a) +{ + int tmp; + + if (a <= 0) a ^= 0xFFFFFFFF; + + return tmp - 1; +} + +void foo(short *K) +{ + short tmp; + short *pptr, P[14]; + + pptr = P; + tmp = bar(*K); + *pptr = (*K << tmp) >> 16; + + if (*P < tmp) + *K++ = 0; +} -- 2.30.2