aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2002-03-28 16:33:52 -0700
committerJeff Law <law@gcc.gnu.org>2002-03-28 16:33:52 -0700
commit8bc528064fedba642b6246c38b8c48e029321766 (patch)
tree77e64e6603c75e448adfa247ed58effe997b148b
parent279dccc5db570d56e327fa74361ecf593038433a (diff)
downloadgcc-8bc528064fedba642b6246c38b8c48e029321766.zip
gcc-8bc528064fedba642b6246c38b8c48e029321766.tar.gz
gcc-8bc528064fedba642b6246c38b8c48e029321766.tar.bz2
re PR rtl-optimization/3311 (GCC-SH: gcc loses result of AND operation due to force_to_mode bug)
* combine.c (simplify_and_const_int): Make sure to apply mask when force_to_mode returns a constant integer. PR3311. From-SVN: r51532
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/combine.c17
2 files changed, 18 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5a8d6fc..a804219 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+Thu Mar 28 16:35:31 2002 Jeffrey A Law (law@redhat.com)
+
+ * combine.c (simplify_and_const_int): Make sure to apply mask
+ when force_to_mode returns a constant integer. PR3311.
+
2002-03-28 John David Anglin <dave@hiauly1.hia.nrc.ca>
* pa-linux.h (LOCAL_LABEL_PREFIX): Define.
diff --git a/gcc/combine.c b/gcc/combine.c
index 0a611870..adb034d 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -7838,14 +7838,23 @@ simplify_and_const_int (x, mode, varop, constop)
int i;
/* Simplify VAROP knowing that we will be only looking at some of the
- bits in it. */
+ bits in it.
+
+ Note by passing in CONSTOP, we guarantee that the bits not set in
+ CONSTOP are not significant and will never be examined. We must
+ ensure that is the case by explicitly masking out those bits
+ before returning. */
varop = force_to_mode (varop, mode, constop, NULL_RTX, 0);
- /* If VAROP is a CLOBBER, we will fail so return it; if it is a
- CONST_INT, we are done. */
- if (GET_CODE (varop) == CLOBBER || GET_CODE (varop) == CONST_INT)
+ /* If VAROP is a CLOBBER, we will fail so return it. */
+ if (GET_CODE (varop) == CLOBBER)
return varop;
+ /* If VAROP is a CONST_INT, then we need to apply the mask in CONSTOP
+ to VAROP and return the new constant. */
+ if (GET_CODE (varop) == CONST_INT)
+ return GEN_INT (trunc_int_for_mode (INTVAL (varop) & constop, mode));
+
/* See what bits may be nonzero in VAROP. Unlike the general case of
a call to nonzero_bits, here we don't care about bits outside
MODE. */