diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d8ee26993cd913f7b5d7ceabf37ebf059572da73..fbf14560fd3dcdb0fcdf08a64e2e07a7b3f59b32 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-02-03  Uros Bizjak  <ubizjak@gmail.com>
+
+	PR middle-end/30667
+	* combine.c (try_combine): Do not substitute source operand
+	with constants wider than 2 * HOST_BITS_PER_WIDE_INT.
+
 2007-02-03  Jan Hubicka  <jh@suse.cz>
 
 	PR gcov-profile/30650
diff --git a/gcc/combine.c b/gcc/combine.c
index aa1e2ce203406d1d4f78f4295126a886436531d6..6605b7a35584ad29bf2bd2a086c6d8ba3d5f432b 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -2003,7 +2003,9 @@ try_combine (rtx i3, rtx i2, rtx i1, int *new_direct_jump_p)
 	    offset = -1;
 	}
 
-      if (offset >= 0)
+      if (offset >= 0
+	  && (GET_MODE_BITSIZE (GET_MODE (SET_DEST (temp)))
+	      <= HOST_BITS_PER_WIDE_INT * 2))
 	{
 	  HOST_WIDE_INT mhi, ohi, ihi;
 	  HOST_WIDE_INT mlo, olo, ilo;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7ec593780d244cca9fcb46d27c3288c17f17e709..2193c95638611ec5174751d4b8e5cb977654fe22 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-02-03  Uros Bizjak  <ubizjak@gmail.com>
+
+	PR middle-end/30667
+	* gfortran.dg/pr30667.f: New test.
+
 2007-02-03  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
 	* gcc.dg/builtins-54.c: Add more cases.
diff --git a/gcc/testsuite/gfortran.dg/pr30667.f b/gcc/testsuite/gfortran.dg/pr30667.f
new file mode 100644
index 0000000000000000000000000000000000000000..0f1af29d1f953415d38ca2d9bb71e87169591135
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr30667.f
@@ -0,0 +1,10 @@
+! { dg-do compile { target i?86-*-* x86_64-*-* } }
+! { dg-require-effective-target ilp32 }
+! { dg-options "-O2 -msse -ftree-vectorize" }
+      subroutine cblank_cvb(a,ndim)
+      character*(*) a
+      character*1 blank
+      data blank/' '/
+      do 100 i=1,ndim
+100   a(i:i)=blank
+      end