diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2001-01-03 06:47:28 +0000 |
---|---|---|
committer | Alexandre Oliva <aoliva@gcc.gnu.org> | 2001-01-03 06:47:28 +0000 |
commit | 8f8d8d6e320ab3397382c296a5eb42258261acaf (patch) | |
tree | 157df1eceb81850325d76e07e3aa784b3de13715 | |
parent | 232a132fd6cf2bdcc637c241d37ae9f3a763861f (diff) | |
download | gcc-8f8d8d6e320ab3397382c296a5eb42258261acaf.zip gcc-8f8d8d6e320ab3397382c296a5eb42258261acaf.tar.gz gcc-8f8d8d6e320ab3397382c296a5eb42258261acaf.tar.bz2 |
combine.c (simplify_shift_const): Even if we're sign-extracting...
* combine.c (simplify_shift_const): Even if we're sign-extracting,
don't discard an ASHIFTRT if we're shifting in a wider mode.
From-SVN: r38648
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/combine.c | 13 |
2 files changed, 14 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cfd6bdd..6f16cc2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2001-01-03 Alexandre Oliva <aoliva@redhat.com> + + * combine.c (simplify_shift_const): Even if we're sign-extracting, + don't discard an ASHIFTRT if we're shifting in a wider mode. + 2000-01-02 John David Anglin <dave@hiauly1.hia.nrc.ca> * toplev.c (rest_of_compilation): Don't print basic block information diff --git a/gcc/combine.c b/gcc/combine.c index e8a478f..23a31ed 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -1,6 +1,6 @@ /* Optimize by combining instructions for GNU compiler. Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000 Free Software Foundation, Inc. + 1999, 2000, 2001 Free Software Foundation, Inc. This file is part of GNU CC. @@ -9130,9 +9130,14 @@ simplify_shift_const (x, code, result_mode, varop, input_count) break; case ASHIFTRT: - /* If we are extracting just the sign bit of an arithmetic right - shift, that shift is not needed. */ - if (code == LSHIFTRT && count == GET_MODE_BITSIZE (result_mode) - 1) + /* If we are extracting just the sign bit of an arithmetic + right shift, that shift is not needed. However, the sign + bit of a wider mode may be different from what would be + interpreted as the sign bit in a narrower mode, so, if + the result is narrower, don't discard the shift. */ + if (code == LSHIFTRT && count == GET_MODE_BITSIZE (result_mode) - 1 + && (GET_MODE_BITSIZE (result_mode) + >= GET_MODE_BITSIZE (GET_MODE (varop)))) { varop = XEXP (varop, 0); continue; |