On Mon, 12 Apr 2021, Jakub Jelinek wrote: > Hi! > > Similarly to PR95450 done on GIMPLE, this patch punts if we try to > simplify_{gen_,}subreg from some constant into the IBM double double > IFmode (or sometimes TFmode) if the double double format wouldn't preserve > the bits. Not all values are valid in IBM double double, e.g. the format > requires that the upper double is the whole value rounded to double, and > if in some cases such as in the pr71522.c testcase with -m32 -Os -mcpu=power7 > some non-floating data is copied through long double variable, we can > simplify a subreg into something that has different value. > > Fixed by punting if the planned simplify_immed_subreg result doesn't > encode to bitwise identical values compared to what we were decoding. > > As for the simplify_gen_subreg change, I think it would be desirable > to just avoid creating SUBREGs of constants on all targets and for all > constants, if simplify_immed_subreg simplified, fine, otherwise punt, > but as we are late in GCC11 development, the patch instead guards this > behavior on MODE_COMPOSITE_P (outermode) - i.e. only conversions to > powerpc{,64,64le} double double long double - and only for the cases where > simplify_immed_subreg was called. > > Bootstrapped/regtested on powerpc64{,le}-linux, on powerpc64-linux tested > with -m32/-m64, ok for trunk?
OK. Richard. > 2021-04-12 Jakub Jelinek <ja...@redhat.com> > > PR target/99648 > * simplify-rtx.c (simplify_immed_subreg): For MODE_COMPOSITE_P > outermode, return NULL if the result doesn't encode back to the > original byte sequence. > (simplify_gen_subreg): Don't create SUBREGs from constants to > MODE_COMPOSITE_P outermode. > > --- gcc/simplify-rtx.c.jj 2021-04-10 12:45:22.189863341 +0200 > +++ gcc/simplify-rtx.c 2021-04-12 12:06:01.469088000 +0200 > @@ -7035,12 +7035,19 @@ simplify_immed_subreg (fixed_size_mode o > while (buffer.length () < buffer_bytes) > buffer.quick_push (filler); > } > - else > + else if (!native_encode_rtx (innermode, x, buffer, first_byte, > inner_bytes)) > + return NULL_RTX; > + rtx ret = native_decode_rtx (outermode, buffer, 0); > + if (ret && MODE_COMPOSITE_P (outermode)) > { > - if (!native_encode_rtx (innermode, x, buffer, first_byte, inner_bytes)) > + auto_vec<target_unit, 128> buffer2 (buffer_bytes); > + if (!native_encode_rtx (outermode, ret, buffer2, 0, buffer_bytes)) > return NULL_RTX; > - } > - return native_decode_rtx (outermode, buffer, 0); > + for (unsigned int i = 0; i < buffer_bytes; ++i) > + if (buffer[i] != buffer2[i]) > + return NULL_RTX; > + } > + return ret; > } > > /* Simplify SUBREG:OUTERMODE(OP:INNERMODE, BYTE) > @@ -7336,6 +7343,13 @@ simplify_context::simplify_gen_subreg (m > || GET_MODE (op) == VOIDmode) > return NULL_RTX; > > + if (MODE_COMPOSITE_P (outermode) > + && (CONST_SCALAR_INT_P (op) > + || CONST_DOUBLE_AS_FLOAT_P (op) > + || CONST_FIXED_P (op) > + || GET_CODE (op) == CONST_VECTOR)) > + return NULL_RTX; > + > if (validate_subreg (outermode, innermode, op, byte)) > return gen_rtx_SUBREG (outermode, op, byte); > > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)