https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92080
--- Comment #9 from Hongtao Liu <liuhongt at gcc dot gnu.org> --- > If we were to expose that vpxor before postreload we'd likely CSE but > we have > > 5: xmm0:V4SI=const_vector > REG_EQUIV const_vector > 6: [`b']=xmm0:V4SI > 7: xmm0:V8HI=const_vector > REG_EQUIV const_vector > 8: [`a']=xmm0:V8HI > > until the very end. But since we have the same mode size on the xmm0 > sets CSE could easily handle (integral) constants by hashing/comparing > on their byte representation rather than by using the RTX structure. > OTOH as we mostly have special constants allowed in the IL like this > treating all-zeros and all-ones specially might be good enough ... We only handle scalar code, guess could do something similar, maybe 1. iteraters over vector modes with same vector length? 2. iteraters over vector modes with same component mode but with bigger vector length? But will miss v8hi/v8si pxor, another alternative is canonicalize const_vector with scalar mode, i.e v4si -> TI, v8si -> OI, v16si -> XI. then we can just query with TI/OI/XImode? 4873 /* See if we have a CONST_INT that is already in a register in a 4874 wider mode. */ 4875 4876 if (src_const && src_related == 0 && CONST_INT_P (src_const) 4877 && is_int_mode (mode, &int_mode) 4878 && GET_MODE_PRECISION (int_mode) < BITS_PER_WORD) 4879 { 4880 opt_scalar_int_mode wider_mode_iter; 4881 FOR_EACH_WIDER_MODE (wider_mode_iter, int_mode) 4882 { 4883 scalar_int_mode wider_mode = wider_mode_iter.require (); 4884 if (GET_MODE_PRECISION (wider_mode) > BITS_PER_WORD) 4885 break; 4886 4887 struct table_elt *const_elt 4888 = lookup (src_const, HASH (src_const, wider_mode), wider_mode); 4889 4890 if (const_elt == 0) 4891 continue; 4892 4893 for (const_elt = const_elt->first_same_value; 4894 const_elt; const_elt = const_elt->next_same_value) 4895 if (REG_P (const_elt->exp)) 4896 { 4897 src_related = gen_lowpart (int_mode, const_elt->exp); 4898 break; 4899 } 4900 4901 if (src_related != 0) 4902 break; 4903 } 4904 }