diff mbox

RFA: Fix type incompatibility in get_addr_base_and_unit_offset_1

Message ID 87mwep1lxh.fsf@talisman.default
State New
Headers show

Commit Message

Richard Sandiford May 10, 2014, 7:19 p.m. UTC
get_addr_base_and_unit_offset_1 and get_ref_base_and_extent have similar
code to handle array indices.  The code in tree-dfa.c extends from the
precision of the index, as before wide-int, but the tree-dfa.h version
was updated in a way that could introduce a type inconsistency (flagged
by a patch I'm working on).  This version makes them the same again,
as per the patch for PR59356.

Tested on x86_64-limux-gnu.  OK to install?

Thanks,
Richard


gcc/
	* tree-dfa.h (get_addr_base_and_unit_offset_1): Update array index
	calculation to match get_ref_base_and_extent.

Comments

Richard Biener May 13, 2014, 8:52 a.m. UTC | #1
On Sat, May 10, 2014 at 9:19 PM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:
> get_addr_base_and_unit_offset_1 and get_ref_base_and_extent have similar
> code to handle array indices.  The code in tree-dfa.c extends from the
> precision of the index, as before wide-int, but the tree-dfa.h version
> was updated in a way that could introduce a type inconsistency (flagged
> by a patch I'm working on).  This version makes them the same again,
> as per the patch for PR59356.
>
> Tested on x86_64-limux-gnu.  OK to install?

Ok.

Thanks,
Richard.

> Thanks,
> Richard
>
>
> gcc/
>         * tree-dfa.h (get_addr_base_and_unit_offset_1): Update array index
>         calculation to match get_ref_base_and_extent.
>
> Index: gcc/tree-dfa.h
> ===================================================================
> --- gcc/tree-dfa.h      2014-05-10 14:02:40.112187344 +0100
> +++ gcc/tree-dfa.h      2014-05-10 14:02:50.414275258 +0100
> @@ -103,7 +103,8 @@ get_addr_base_and_unit_offset_1 (tree ex
>                     TREE_CODE (unit_size) == INTEGER_CST))
>               {
>                 offset_int woffset
> -                 = offset_int::from (wi::sub (index, low_bound), SIGNED);
> +                 = wi::sext (wi::to_offset (index) - wi::to_offset (low_bound),
> +                             TYPE_PRECISION (TREE_TYPE (index)));
>                 woffset *= wi::to_offset (unit_size);
>                 byte_offset += woffset.to_shwi ();
>               }
diff mbox

Patch

Index: gcc/tree-dfa.h
===================================================================
--- gcc/tree-dfa.h	2014-05-10 14:02:40.112187344 +0100
+++ gcc/tree-dfa.h	2014-05-10 14:02:50.414275258 +0100
@@ -103,7 +103,8 @@  get_addr_base_and_unit_offset_1 (tree ex
 		    TREE_CODE (unit_size) == INTEGER_CST))
 	      {
 		offset_int woffset
-		  = offset_int::from (wi::sub (index, low_bound), SIGNED);
+		  = wi::sext (wi::to_offset (index) - wi::to_offset (low_bound),
+			      TYPE_PRECISION (TREE_TYPE (index)));
 		woffset *= wi::to_offset (unit_size);
 		byte_offset += woffset.to_shwi ();
 	      }