From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 37A393854141; Fri, 21 Oct 2022 09:42:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37A393854141 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666345358; bh=vd426s9RwehrUaJL45kaGR15qsRNFcEX9IQQODWBoaE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PiHSpR0J8qUgSg1TSHAhhtCdCnBOr5fWMd3614twBaqJ0nq4J6X+AnOWg/sQqcvu0 gt8cxYtGbR6oNGEST9gxiN/J6t+eBWz5gHunjULrD2e3kvZrujZN2+Qu09LOA/NO2+ v53Mfo5qiguajBBMLlgvmkY6iD3Vs4+SX/cQ3Bqo= From: "linkw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug testsuite/107338] new test case gcc.dg/vect/vect-bitfield-read-7.c in r13-3413-ge10ca9544632db fails Date: Fri, 21 Oct 2022 09:42:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: testsuite X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: testsuite-fail X-Bugzilla-Severity: normal X-Bugzilla-Who: linkw at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_reconfirmed_on bug_status cc everconfirmed Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107338 Kewen Lin changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2022-10-21 Status|UNCONFIRMED |NEW CC| |linkw at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Kewen Lin --- Confirmed, this issue is BE specific. vect__ifc__10.14_55 =3D MEM [(struct s *)_= 22]; vect__ifc__10.15_57 =3D MEM [(struct s *)_= 22 + 16B]; vect_perm_even_58 =3D VEC_PERM_EXPR ; vect_patt_7.16_60 =3D [vec_unpack_hi_expr] vect_perm_even_58; vect_patt_7.16_61 =3D [vec_unpack_lo_expr] vect_perm_even_58; vect_patt_30.17_63 =3D vect_patt_7.16_60 & { 15728640, 15728640, 15728640, 15728640 }; vect_patt_30.17_64 =3D vect_patt_7.16_61 & { 15728640, 15728640, 15728640, 15728640 }; vect_patt_31.18_66 =3D vect_patt_30.17_63 >> 20; vect_patt_31.18_67 =3D vect_patt_30.17_64 >> 20; The mask 15728640 (0xF00000) and shifting count 20 look wrong here, the used prec is incorrect, after the hunk /* We move the conversion earlier if the loaded type is smaller than the return type to enable the use of widening loads. */ if (TYPE_PRECISION (TREE_TYPE (container)) < TYPE_PRECISION (ret_type) && !useless_type_conversion_p (TREE_TYPE (container), ret_type)) { pattern_stmt =3D gimple_build_assign (vect_recog_temp_ssa_var (ret_type), NOP_EXPR, container); container =3D gimple_get_lhs (pattern_stmt); container_type =3D TREE_TYPE (container); vectype =3D get_vectype_for_scalar_type (vinfo, container_type); append_pattern_def_seq (vinfo, stmt_info, pattern_stmt, vectype); } container_type has become to have precision 32. Although due to widening lo= ads the resulted vector element have precision 32, actually the low 16 bis are = the data what we want, the prec should use the one before the above adjustment. If I moved the prec calculation ahead of this hunk, the case can pass. diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index 777ba2f5903..d7893f7f3bd 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -1925,6 +1925,12 @@ vect_recog_bitfield_ref_pattern (vec_info *vinfo, stmt_vec_info stmt_info, tree container_type =3D TREE_TYPE (container); tree vectype =3D get_vectype_for_scalar_type (vinfo, container_type); + unsigned HOST_WIDE_INT shift_n =3D bit_field_offset (bf_ref).to_constant= (); + unsigned HOST_WIDE_INT mask_width =3D bit_field_size (bf_ref).to_constan= t (); + unsigned HOST_WIDE_INT prec =3D tree_to_uhwi (TYPE_SIZE (container_type)= ); + if (BYTES_BIG_ENDIAN) + shift_n =3D prec - shift_n - mask_width; + /* We move the conversion earlier if the loaded type is smaller than the return type to enable the use of widening loads. */ if (TYPE_PRECISION (TREE_TYPE (container)) < TYPE_PRECISION (ret_type) @@ -1953,12 +1959,6 @@ vect_recog_bitfield_ref_pattern (vec_info *vinfo, stmt_vec_info stmt_info, shift_first =3D false; } - unsigned HOST_WIDE_INT shift_n =3D bit_field_offset (bf_ref).to_constant= (); - unsigned HOST_WIDE_INT mask_width =3D bit_field_size (bf_ref).to_constan= t (); - unsigned HOST_WIDE_INT prec =3D tree_to_uhwi (TYPE_SIZE (container_type)= ); - if (BYTES_BIG_ENDIAN) - shift_n =3D prec - shift_n - mask_width; - /* If we don't have to shift we only generate the mask, so just fix the code-path to shift_first. */ if (shift_n =3D=3D 0)=