From a79b863a00888e242f9ceda4f1f70a8772ecf727 Mon Sep 17 00:00:00 2001
From: zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 17 Jun 2004 17:03:11 +0000
Subject: [PATCH] 	* expmed.c (expand_mult_const): In sanity check,
 compare only 	the bits of val and val_so_far that are significant in the 
 result mode.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83294 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog | 8 +++++++-
 gcc/expmed.c  | 4 ++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 551a2ec87920..5a1a3c205a0e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2004-06-17  Zack Weinberg  <zack@codesourcery.com>
+
+	* expmed.c (expand_mult_const): In sanity check, compare only
+	the bits of val and val_so_far that are significant in the
+	result mode.
+
 2004-06-17  Daniel Berlin  <dberlin@dberlin.org>
 
 	* tree-ssa-pre.c:  Update comments.
@@ -198,7 +204,7 @@
 2004-06-16  Daniel Berlin  <dberlin@dberlin.org>
 
 	* tree-cfg.c (pass_split_crit_edge): Give it a name and a dump file.
-	
+
 2004-06-16  Dale Johannesen  <dalej@apple.com>
 
 	* loop.c (loop_givs_reduce): Avoid miscompilation of
diff --git a/gcc/expmed.c b/gcc/expmed.c
index fb590cdf6730..ae76695a133b 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -2610,6 +2610,10 @@ expand_mult_const (enum machine_mode mode, rtx op0, HOST_WIDE_INT val,
       accum = force_operand (gen_rtx_PLUS (mode, accum, op0), target);
     }
 
+  /* Compare only the bits of val and val_so_far that are significant
+     in the result mode, to avoid sign-/zero-extension confusion.  */
+  val &= GET_MODE_MASK (mode);
+  val_so_far &= GET_MODE_MASK (mode);
   if (val != val_so_far)
     abort ();
 
-- 
GitLab