On Tue, Jul 3, 2018 at 12:57 PM Andrew Stubbs <andrew_stu...@mentor.com> wrote: > > On 03/07/18 11:33, Andrew Stubbs wrote: > > On 03/07/18 11:15, Richard Biener wrote: > >> AVX ones are all UNSPECs I believe - how do your patterns look like? > > > > AVX has both unspec and vec_merge variants (at least for define_expand, > > in GCC8), but in any case, AFAICT dse.c only cares about the destination > > MEM, and all the AVX and SVE patterns appear to use nothing special there. > > Sorry, my patterns look something like this: > > (set (mem:V64DI (reg:DI) > (vec_merge:V64DI (reg:V64DI) (unspec ...) (reg:DI))) > > Where the unspec just means that the destination remains unchanged. We > could also use (match_dup 0) there, but we don't, so probably there was > an issue with that at some point.
I believe that the AVX variants like (define_expand "maskstore<mode><avx512fmaskmodelower>" [(set (match_operand:V48_AVX512VL 0 "memory_operand") (vec_merge:V48_AVX512VL (match_operand:V48_AVX512VL 1 "register_operand") (match_dup 0) (match_operand:<avx512fmaskmode> 2 "register_operand")))] "TARGET_AVX512F") are OK since they represent a use of the memory due to the match_dup 0 while your UNSPEC one doesn't so as the store doesn't actually take place to all of 0 your insn variant doesn't represent observable behavior. > >>> I was thinking of solving the problem by adding a target hook to query > >>> the true length of vector types. Any thoughts on that? > >> > >> It isn't about the length but about the mask because there can be mask > >> values that do not affect the length? > > > > The problem I have right now is that the vector write conflicts with > > writes to distinct variables, in which case the vector length is what's > > important, and it's probably(?) safe to assume that if the vector mask > > is not constant then space for the whole vector has been allocated on > > the stack. > > > > But yes, in general it's true that subsequent writes to the same vector > > could well write distinct elements, in which case the value of the mask > > is significant to DSE analysis. > > > > Andrew >