Commit 322913f8 by Eric Botcazou Committed by Eric Botcazou

expr.c (expand_expr_real_1): For a bit-field destination type...

	* expr.c (expand_expr_real_1) <case VIEW_CONVERT_EXPR>: For a bit-field
	destination type, extract only the valid bits if the source type is not
	integral and has a different mode.

From-SVN: r207902
parent ffdeb702
2014-02-19 Eric Botcazou <ebotcazou@adacore.com>
* expr.c (expand_expr_real_1) <case VIEW_CONVERT_EXPR>: For a bit-field
destination type, extract only the valid bits if the source type is not
integral and has a different mode.
2014-02-19 Richard Biener <rguenther@suse.de> 2014-02-19 Richard Biener <rguenther@suse.de>
PR ipa/60243 PR ipa/60243
......
...@@ -10436,6 +10436,11 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, ...@@ -10436,6 +10436,11 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
else if (INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (treeop0))) else if (INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (treeop0)))
op0 = convert_modes (mode, GET_MODE (op0), op0, op0 = convert_modes (mode, GET_MODE (op0), op0,
TYPE_UNSIGNED (TREE_TYPE (treeop0))); TYPE_UNSIGNED (TREE_TYPE (treeop0)));
/* If the output type is a bit-field type, do an extraction. */
else if (reduce_bit_field)
return extract_bit_field (op0, TYPE_PRECISION (type), 0,
TYPE_UNSIGNED (type), NULL_RTX,
mode, mode);
/* As a last resort, spill op0 to memory, and reload it in a /* As a last resort, spill op0 to memory, and reload it in a
different mode. */ different mode. */
else if (!MEM_P (op0)) else if (!MEM_P (op0))
...@@ -10458,10 +10463,10 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, ...@@ -10458,10 +10463,10 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
op0 = target; op0 = target;
} }
/* At this point, OP0 is in the correct mode. If the output type is /* If OP0 is (now) a MEM, we need to deal with alignment issues. If the
such that the operand is known to be aligned, indicate that it is. output type is such that the operand is known to be aligned, indicate
Otherwise, we need only be concerned about alignment for non-BLKmode that it is. Otherwise, we need only be concerned about alignment for
results. */ non-BLKmode results. */
if (MEM_P (op0)) if (MEM_P (op0))
{ {
enum insn_code icode; enum insn_code icode;
......
2014-02-19 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/opt31.adb: New test.
2014-02-19 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2014-02-19 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* gcc.dg/torture/pr60092.c: xfail execution on *-*-solaris2.11* at -O0. * gcc.dg/torture/pr60092.c: xfail execution on *-*-solaris2.11* at -O0.
......
-- { dg-do run }
-- { dg-options "-O" }
with Interfaces; use Interfaces;
with Unchecked_Conversion;
procedure Opt31 is
type Unsigned_24 is new Unsigned_32 range 0 .. 2**24 - 1;
subtype Time_T is Unsigned_24 range 0 .. 24 * 60 * 60 * 128 - 1;
type Messages_T is array (Positive range <>) of Unsigned_8;
subtype T_3Bytes is Messages_T (1 .. 3);
type Rec1 is record
F : Time_T;
end record;
for Rec1 use record
F at 0 range 0 .. 23;
end record;
for Rec1'Size use 24;
type Rec2 is record
I1,I2,I3,I4 : Integer;
R1 : Rec1;
end record;
function Conv is new Unchecked_Conversion (T_3Bytes, Rec1);
procedure Decode (M : Messages_T) is
My_Rec2 : Rec2;
begin
My_Rec2.R1 := Conv (M (1 .. 3));
if not My_Rec2.R1.F'Valid then
raise Program_Error;
end if;
end;
Message : Messages_T (1 .. 4) := (16#18#, 16#0C#, 16#0C#, 16#18#);
begin
Decode (Message);
end;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment