On 9/6/19 12:02 AM, Bernd Edlinger wrote:
> Hi,
> 
> 
> as discussed already I propose this little refactoring as a follow-up
> which is not supposed to be doing any change to the code generation.
> 
> I tried to get the description of ALT_RTL right, since it changed
> quite a lot recently what this weird parameter does, and nobody
> cared to update the comments :-/
> 
> I stared a while at the VCE expansion, and I kind of think that
> there is probably still something not quite right there,
> since we expand
> 
>            orig_op0
>               = expand_expr_real (tem,
>                                   (TREE_CODE (TREE_TYPE (tem)) == UNION_TYPE
>                                    && (TREE_CODE (TYPE_SIZE (TREE_TYPE (tem)))
>                                        != INTEGER_CST)
>                                    && modifier != EXPAND_STACK_PARM
>                                    ? target : NULL_RTX),
>                                   VOIDmode,
>                                   modifier == EXPAND_SUM ? EXPAND_NORMAL : 
> modifier,
>                                   NULL, true);
> 
> so inner_reference_p = true we want the memory address, maybe unaligned.
> But later op0 is used in a context where it needs to be aligned:
> 
>       else if (INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE 
> (treeop0)))
>         op0 = convert_modes (mode, GET_MODE (op0), op0,
>                              TYPE_UNSIGNED (TREE_TYPE (treeop0)));
> 
> and especially this:
> 
>           if (modifier != EXPAND_WRITE
>               && modifier != EXPAND_MEMORY
>               && !inner_reference_p
>               && mode != BLKmode
>               && MEM_ALIGN (op0) < GET_MODE_ALIGNMENT (mode))
>             {
>                   [...]
>                   if (GET_MODE (op0) == BLKmode)
>                     {
>                       rtx size_rtx = gen_int_mode (mode_size, Pmode);
>                       emit_block_move (new_with_op0_mode, op0, size_rtx,
>                                        (modifier == EXPAND_STACK_PARM
>                                         ? BLOCK_OP_CALL_PARM
>                                         : BLOCK_OP_NORMAL));
>                     }
>                   else
>                     emit_move_insn (new_with_op0_mode, op0);
> 
> ?
> 
> I think this kind of stuff happens more often in Ada, but at least in the Ada
> test suite there was nothing triggering any of the sanitation assertions.
> 
> But time will tell.
> 
> 
> Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
> Is it OK for trunk?
> 
> 
> Thanks
> Bernd.
> 
> 
> patch-expand-misalign.diff
> 
> 2019-09-04  Bernd Edlinger  <bernd.edlin...@hotmail.de>
> 
>       * expmed.c (extract_bit_field): Update function comment
>       regarding alt_rtl.
>       * expr.c (expand_expr_real): Update function comment
>       regarding alt_rtl.
>       (expand_misaligned_mem_ref): New helper function.
>       (expand_expr_real_2): Use expand_misaligned_mem_ref.
>       Remove duplicate assignment to "base" at case MEM_REF.
>       Remove a shadowed variable "unsignedp" at case VCE. 
> 
OK

jeff

Reply via email to