Fix ccp bit_value_binop_1 (PR tree-optimization/47155)

Submitted by Jakub Jelinek on Jan. 3, 2011, 2:33 p.m.

Details

Message ID 20110103143300.GC16156@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Jan. 3, 2011, 2:33 p.m.
Hi!

My recent tree-ssa-ccp.c change broke the following testcase.
It is correct that the type used is the lhs type, but uns
needs to be taken from r1type instead of type, at least for the comparisons.
For non-comparisons I believe it ought to be the same as type (or uselessly
convertible to it) and most of the callers pass the exactly same type
to that function for both type and r1type anyway.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2011-01-03  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/47155
	* tree-ssa-ccp.c (bit_value_binop_1): Use r1type instead of type
	when computing uns.

	* gcc.c-torture/execute/pr47155.c: New test.


	Jakub

Comments

Jeff Law Jan. 3, 2011, 4:28 p.m.
On 01/03/11 07:33, Jakub Jelinek wrote:
> Hi!
>
> My recent tree-ssa-ccp.c change broke the following testcase.
> It is correct that the type used is the lhs type, but uns
> needs to be taken from r1type instead of type, at least for the comparisons.
> For non-comparisons I believe it ought to be the same as type (or uselessly
> convertible to it) and most of the callers pass the exactly same type
> to that function for both type and r1type anyway.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2011-01-03  Jakub Jelinek<jakub@redhat.com>
>
> 	PR tree-optimization/47155
> 	* tree-ssa-ccp.c (bit_value_binop_1): Use r1type instead of type
> 	when computing uns.
>
> 	* gcc.c-torture/execute/pr47155.c: New test.
OK.
Jeff
H.J. Lu Jan. 30, 2011, 6:11 p.m.
On Mon, Jan 3, 2011 at 6:33 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> My recent tree-ssa-ccp.c change broke the following testcase.
> It is correct that the type used is the lhs type, but uns
> needs to be taken from r1type instead of type, at least for the comparisons.
> For non-comparisons I believe it ought to be the same as type (or uselessly
> convertible to it) and most of the callers pass the exactly same type
> to that function for both type and r1type anyway.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2011-01-03  Jakub Jelinek  <jakub@redhat.com>
>
>        PR tree-optimization/47155
>        * tree-ssa-ccp.c (bit_value_binop_1): Use r1type instead of type
>        when computing uns.
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47538

Patch hide | download patch | download mbox

--- gcc/tree-ssa-ccp.c.jj	2011-01-03 09:54:28.000000000 +0100
+++ gcc/tree-ssa-ccp.c	2011-01-03 10:19:06.000000000 +0100
@@ -1764,8 +1764,8 @@  bit_value_binop_1 (enum tree_code code, 
 		   tree r1type, double_int r1val, double_int r1mask,
 		   tree r2type, double_int r2val, double_int r2mask)
 {
-  bool uns = (TREE_CODE (type) == INTEGER_TYPE
-	      && TYPE_IS_SIZETYPE (type) ? 0 : TYPE_UNSIGNED (type));
+  bool uns = (TREE_CODE (r1type) == INTEGER_TYPE
+	      && TYPE_IS_SIZETYPE (r1type) ? 0 : TYPE_UNSIGNED (r1type));
   /* Assume we'll get a constant result.  Use an initial varying value,
      we fall back to varying in the end if necessary.  */
   *mask = double_int_minus_one;
--- gcc/testsuite/gcc.c-torture/execute/pr47155.c.jj	2011-01-03 10:27:55.000000000 +0100
+++ gcc/testsuite/gcc.c-torture/execute/pr47155.c	2011-01-03 10:27:38.000000000 +0100
@@ -0,0 +1,14 @@ 
+/* PR tree-optimization/47155 */
+
+unsigned int a;
+static signed char b = -127;
+int c = 1;
+
+int
+main (void)
+{
+  a = b <= (unsigned char) (-6 * c);
+  if (!a)
+    __builtin_abort ();
+  return 0;
+}