This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 0/2] Convert s390 to atomic optabs, v2


Richard Henderson wrote:


While the first set of changes looks good to me, I don't understand those:

> @@ -4728,7 +4733,12 @@ init_alignment_context (struct alignment_context *ac, rtx mem,
>    ac->aligned = (MEM_ALIGN (mem) >= GET_MODE_BITSIZE (SImode));
>  
>    if (ac->aligned)
> -    ac->memsi = adjust_address (mem, SImode, 0); /* Memory is aligned.  */
> +    {
> +      ac->memsi = adjust_address (mem, SImode, 0); /* Memory is aligned.  */
> +      ac->shift = const0_rtx;
> +      ac->modemask = GEN_INT (GET_MODE_MASK (mode));
> +      ac->modemaski = GEN_INT (~GET_MODE_MASK (mode));
> +    }
>    else
>      {
>        /* Alignment is unknown.  */
> @@ -4755,15 +4765,17 @@ init_alignment_context (struct alignment_context *ac, rtx mem,
>        ac->shift = expand_simple_binop (SImode, MINUS, ac->shift, byteoffset,
>  				      NULL_RTX, 1, OPTAB_DIRECT);
>  
> +      /* Shift is the byte count, but we need the bitcount.  */
> +      ac->shift = expand_simple_binop (SImode, ASHIFT, ac->shift, GEN_INT (3),
> +				       NULL_RTX, 1, OPTAB_DIRECT);
> +
> +      /* Calculate masks.  */
> +      ac->modemask = expand_simple_binop (SImode, ASHIFT,
> +					  GEN_INT (GET_MODE_MASK (mode)),
> +					  ac->shift, NULL_RTX, 1, OPTAB_DIRECT);
> +      ac->modemaski = expand_simple_unop (SImode, NOT, ac->modemask,
> +					  NULL_RTX, 1);
>      }
> -  /* Shift is the byte count, but we need the bitcount.  */
> -  ac->shift = expand_simple_binop (SImode, MULT, ac->shift, GEN_INT (BITS_PER_UNIT),
> -				  NULL_RTX, 1, OPTAB_DIRECT);
> -  /* Calculate masks.  */
> -  ac->modemask = expand_simple_binop (SImode, ASHIFT,
> -				     GEN_INT (GET_MODE_MASK (mode)), ac->shift,
> -				     NULL_RTX, 1, OPTAB_DIRECT);
> -  ac->modemaski = expand_simple_unop (SImode, NOT, ac->modemask, NULL_RTX, 1);
>  }
>  
>  /* A subroutine of s390_expand_cs_hqi.  Insert INS into VAL.  If possible,
> @@ -4781,7 +4793,7 @@ s390_two_part_insv (struct alignment_context *ac, rtx *seq1, rtx *seq2,
>        start_sequence ();
>        tmp = copy_to_mode_reg (SImode, val);
>        if (s390_expand_insv (tmp, GEN_INT (GET_MODE_BITSIZE (mode)),
> -			    const0_rtx, ins))
> +			    GEN_INT (32 - GET_MODE_BITSIZE (mode)), ins))
>  	{
>  	  *seq1 = NULL;
>  	  *seq2 = get_insns ();

"aligned" accesses do involve the *most significant* part of the word
(on a big-endian machine), which means ac->shift has to be set to
modesize (outer) - modesize (inner), and expand_insv needs to be
called with bitpos 0 (due to bits-big-endian).

When reverting this part of your patch (and together with the EQ/NE fix
pointed out here: http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00170.html),
I can complete a bootstrap/testing cycle without regressions.

(There's still code being generated that looks a bit inefficient, but that's
a different story.)

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]