genmodes: Update GET_MODE_MASK when changing NUNITS [PR98214]
authorRichard Sandiford <richard.sandiford@arm.com>
Thu, 31 Dec 2020 16:10:47 +0000 (16:10 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Thu, 31 Dec 2020 16:10:47 +0000 (16:10 +0000)
commit0411210fddbd3ec27c8dc1183f40f662712a2232
tree8e8148d489ca4378607eb44f5cc7f1da15d9343f
parentd2eb616a0f7bea78164912aa438c29fe1ef5774a
genmodes: Update GET_MODE_MASK when changing NUNITS [PR98214]

The static GET_MODE_MASKs for SVE vectors are based on the
static precisions, which in turn are based on 128-bit SVE.
The precisions are later updated based on -msve-vector-bits
(usually to become variable length), but the GET_MODE_MASK
stayed the same.  This caused combine to fold:

  (*_extract:DI (subreg:DI (reg:VNxMM R) 0) ...)

to zero because the extracted bits appeared to be insignificant.

gcc/
PR rtl-optimization/98214
* genmodes.c (emit_insn_modes_h): Emit a definition of CONST_MODE_MASK.
(emit_mode_mask): Treat mode_mask_array as non-constant if adj_nunits.
(emit_mode_adjustments): Update GET_MODE_MASK when updating
GET_MODE_NUNITS.
* machmode.h (mode_mask_array): Use CONST_MODE_MASK.
gcc/genmodes.c
gcc/machmode.h
gcc/testsuite/gcc.target/aarch64/sve/pr98214.c [new file with mode: 0644]