Patchwork Compare precisions with precisions in fold-const

login
register
mail settings
Submitter Bernd Schmidt
Date April 11, 2012, 1:59 p.m.
Message ID <4F858E5B.1070803@codesourcery.com>
Download mbox | patch
Permalink /patch/151798/
State New
Headers show

Comments

Bernd Schmidt - April 11, 2012, 1:59 p.m.
This is another problem I found working on a new target. In fold-const,
when folding conversions, there are two instances where mode bitsizes
are compared to type precisions. This fails to do the right thing if
mode precision and bitsize differ (which I believe they currently don't
on any target).

Bootstrapped and regression tested on i686-linux. Ok?


Bernd
* fold-const.c (fold_unary_loc): Use GET_MODE_PRECISION for
	comparisons against TYPE_PRECISION.
Richard Guenther - April 11, 2012, 2:11 p.m.
On Wed, Apr 11, 2012 at 3:59 PM, Bernd Schmidt <bernds@codesourcery.com> wrote:
> This is another problem I found working on a new target. In fold-const,
> when folding conversions, there are two instances where mode bitsizes
> are compared to type precisions. This fails to do the right thing if
> mode precision and bitsize differ (which I believe they currently don't
> on any target).
>
> Bootstrapped and regression tested on i686-linux. Ok?

Ok.  Please also adjust the corresponding duplicate code in tree-ssa-forwprop.c

Thanks,
Richard.

>
> Bernd
Mike Stump - April 11, 2012, 3:01 p.m.
On Apr 11, 2012, at 6:59 AM, Bernd Schmidt wrote:
> This is another problem I found working on a new target. In fold-const,
> when folding conversions, there are two instances where mode bitsizes
> are compared to type precisions. This fails to do the right thing if
> mode precision and bitsize differ (which I believe they currently don't
> on any target).

They do on mine...  In my genmodes patch, it would make it true on two existing gcc ports as I recall.

Patch

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c	(revision 365109)
+++ gcc/fold-const.c	(working copy)
@@ -8586,7 +8586,7 @@  fold_unary_loc (location_t loc, enum tre
 	      && inter_prec >= inside_prec
 	      && (inter_float || inter_vec
 		  || inter_unsignedp == inside_unsignedp)
-	      && ! (final_prec != GET_MODE_BITSIZE (TYPE_MODE (type))
+	      && ! (final_prec != GET_MODE_PRECISION (TYPE_MODE (type))
 		    && TYPE_MODE (type) == TYPE_MODE (inter_type))
 	      && ! final_ptr
 	      && (! final_vec || inter_prec == inside_prec))
@@ -8620,7 +8620,7 @@  fold_unary_loc (location_t loc, enum tre
 		  == (final_unsignedp && final_prec > inter_prec))
 	      && ! (inside_ptr && inter_prec != final_prec)
 	      && ! (final_ptr && inside_prec != inter_prec)
-	      && ! (final_prec != GET_MODE_BITSIZE (TYPE_MODE (type))
+	      && ! (final_prec != GET_MODE_PRECISION (TYPE_MODE (type))
 		    && TYPE_MODE (type) == TYPE_MODE (inter_type)))
 	    return fold_build1_loc (loc, code, type, TREE_OPERAND (op0, 0));
 	}