This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, vectorizer]: Fix PR tree-optimization/33846, ICE in trunc_int_for_mode, at explow.c:55


Hello!

For the testcase, described in the PR trail, we call
trunc_int_for_mode with V4SImode and this ICEs in explow.c:55.

The fix is simply to pass inner mode of the vector mode to the
trunc_int_for_mode when shift-by-constant-scalar-value RTX is
processed. I have checked that the loop is still vecotrized (and
expected result is produced).

Patch was bootstrapped and regression tested on i686-pc-linux-gnu.

OK for mainline?

2007-10-22  Uros Bizjak  <ubizjak@gmail.com>

	PR tree-optimization/33846
	* combine.c (simplify_shift_const_1): Use inner mode for vector
	shift_mode in the call to trunc_int_for_mode when varop == XOR.

testsuite/ChangeLog:

2007-10-22  Uros Bizjak  <ubizjak@gmail.com>

	PR tree-optimization/33846
	* gcc.dg/vect/pr33846.c: New testcase.

Uros.

Index: testsuite/gcc.dg/vect/pr33846.c
===================================================================
--- testsuite/gcc.dg/vect/pr33846.c     (revision 0)
+++ testsuite/gcc.dg/vect/pr33846.c     (revision 0)
@@ -0,0 +1,21 @@
+/* Testcase by Martin Michlmayr <tbm@cyrius.com> */
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_shift } */
+
+int clamp_val (int i)
+{
+  return ~i >> 31;
+}
+void _mix_some_samples (long buf, int *mix_buffer, int mix_size)
+{
+  int i;
+  signed int *p = mix_buffer;
+  for (i = mix_size ; i > 0; i--)
+  {
+    *((short *) buf) = clamp_val ((*p) + 0x800000);
+    buf += 2;
+    p++;
+  }
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: combine.c
===================================================================
--- combine.c   (revision 129547)
+++ combine.c   (working copy)
@@ -9386,7 +9386,9 @@ simplify_shift_const_1 (enum rtx_code co
                 constant has its sign bit set in shift_mode.  */
              && !(code == ASHIFTRT && GET_CODE (varop) == XOR
                   && 0 > trunc_int_for_mode (INTVAL (XEXP (varop, 1)),
-                                             shift_mode))
+                                             VECTOR_MODE_P (shift_mode)
+                                             ? GET_MODE_INNER (shift_mode)
+                                             : shift_mode))
              && (new = simplify_const_binary_operation (code, result_mode,
                                                         XEXP (varop, 1),
                                                         GEN_INT (count))) != 0
@@ -9405,7 +9407,9 @@ simplify_shift_const_1 (enum rtx_code co
          if (GET_CODE (XEXP (varop, 1)) == CONST_INT
             && !(code == ASHIFTRT && GET_CODE (varop) == XOR
                  && 0 > trunc_int_for_mode (INTVAL (XEXP (varop, 1)),
-                                            shift_mode)))
+                                            VECTOR_MODE_P (shift_mode)
+                                            ? GET_MODE_INNER (shift_mode)
+                                            : shift_mode)))
            {
              rtx lhs = simplify_shift_const (NULL_RTX, code, shift_mode,
                                              XEXP (varop, 0), count);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]