From e4c9f3c21dd0075a6b1f0deb1241b7cb4b9cf944 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 20 Jan 2007 02:04:31 +0000 Subject: [PATCH] expmed.c (expand_divmod): Cast constant to unsigned HOST_WIDE_INT before negating. * expmed.c (expand_divmod) [TRUNC_MOD_EXPR, TRUNC_DIV_EXPR]: Cast constant to unsigned HOST_WIDE_INT before negating. From-SVN: r120995 --- gcc/ChangeLog | 5 +++++ gcc/expmed.c | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d5eb9aec686..97483ccc293 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2007-01-19 Ian Lance Taylor + + * expmed.c (expand_divmod) [TRUNC_MOD_EXPR, TRUNC_DIV_EXPR]: Cast + constant to unsigned HOST_WIDE_INT before negating. + 2007-01-19 Ian Lance Taylor * tree-ssa-operands.h (struct vuse_vec_d): Change num_vuse field diff --git a/gcc/expmed.c b/gcc/expmed.c index e12fdfbb103..58b6a635a6a 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -1,7 +1,7 @@ /* Medium-level subroutines: convert bit-field store and extract and shifts, multiplies and divides to rtl instructions. Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This file is part of GCC. @@ -4174,7 +4174,9 @@ expand_divmod (int rem_flag, enum tree_code code, enum machine_mode mode, int lgup, post_shift; rtx mlr; HOST_WIDE_INT d = INTVAL (op1); - unsigned HOST_WIDE_INT abs_d = d >= 0 ? d : -d; + unsigned HOST_WIDE_INT abs_d; + + abs_d = d >= 0 ? d : - (unsigned HOST_WIDE_INT) d; /* n rem d = n rem -d */ if (rem_flag && d < 0) -- 2.30.2