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] Fix PR39588, ICE in trunc_int_for_mode


During combine we try to simplify

(ashift:V4SI (neg:V4SI (reg:V4SI 87))
    (const_int 1 [0x1]))

to

(neg:V4SI (ashift:V4Si (reg:V4SI 87)
    (const_int 1 [0x1]))

and end up calling merge_outer_ops with zero const1 and V4SImode which
eventually (and needlessly) gets truncated by

8977      const0 = trunc_int_for_mode (const0, mode);

which obviously fails for V4SImode.  A simple fix that works for all
the shift combine simplifications is to skip the truncation if the
constant is zero.

This is what the following patch does.

Bootstrap and regtest in progress - does this look ok?

Thanks,
Richard.

2009-03-30  Richard Guenther  <rguenther@suse.de>

	PR rtl-optimization/39588
	* combine.c (merge_outer_ops): Do not truncate zero.

	* gcc.c-torture/compile/pr39588.c: New testcase.

Index: gcc/combine.c
===================================================================
*** gcc/combine.c	(revision 145291)
--- gcc/combine.c	(working copy)
*************** merge_outer_ops (enum rtx_code *pop0, HO
*** 8974,8980 ****
    /* ??? Slightly redundant with the above mask, but not entirely.
       Moving this above means we'd have to sign-extend the mode mask
       for the final test.  */
!   const0 = trunc_int_for_mode (const0, mode);
  
    *pop0 = op0;
    *pconst0 = const0;
--- 8974,8981 ----
    /* ??? Slightly redundant with the above mask, but not entirely.
       Moving this above means we'd have to sign-extend the mode mask
       for the final test.  */
!   if (const0 != 0)
!     const0 = trunc_int_for_mode (const0, mode);
  
    *pop0 = op0;
    *pconst0 = const0;
Index: gcc/testsuite/gcc.c-torture/compile/pr39588.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr39588.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr39588.c	(revision 0)
***************
*** 0 ****
--- 1,8 ----
+ #define lit_from_int(in) ((in<0)?(((-in)<<1)|1):(in<<1))
+ void init_clause(int* literals, int size, int *lits)
+ {
+   int i;
+   for(i=0; i < size; i++)
+     lits[i] = lit_from_int(literals[i]);
+ }
+ 


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