From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EF7B6385B83B; Wed, 23 Feb 2022 07:41:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF7B6385B83B From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104595] unvectorized loop due to bool condition loaded from memory Date: Wed, 23 Feb 2022 07:41:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Feb 2022 07:41:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104595 --- Comment #9 from rguenther at suse dot de --- On Wed, 23 Feb 2022, linkw at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104595 >=20 > --- Comment #8 from Kewen Lin --- > I had one local hack and just found it can survive on x86 bootstrapping a= nd > regression testing. I guess maybe it's good to post here. Just ignore thi= s if > it looks like noise. :) The point is to do the conversion for the loaded = bool > value from memory, normally it should be like a nop, but for this test ca= se, it > can help us to generate the expected char comparison. Yes, but see my posted patch for a better fix. There's some underlying missing things we have in bool pattern recog that need to be fixed. Treating "external" (that includes memory) bools as 'char' would work but the type has effect on other IL which causes some ripple down effect and thus I think doing this isn't going to work in the end. > diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc > index 2baf974627e..d4b8920203b 100644 > --- a/gcc/tree-vect-patterns.cc > +++ b/gcc/tree-vect-patterns.cc > @@ -3911,6 +3911,11 @@ check_bool_pattern (tree var, vec_info *vinfo, > hash_set &stmts) > return false; > break; >=20 > + case ARRAY_REF: > + if (TYPE_PRECISION (TREE_TYPE (var)) !=3D 1) > + return false; > + break; > + > default: > if (TREE_CODE_CLASS (rhs_code) =3D=3D tcc_comparison) > { > @@ -4005,6 +4010,19 @@ adjust_bool_pattern (vec_info *vinfo, tree var, tr= ee > out_type, > SSA_NAME, irhs1); > break; >=20 > + case ARRAY_REF: > + { > + itype =3D TREE_TYPE (var); > + gcc_assert (TYPE_PRECISION (itype) =3D=3D 1); > + machine_mode mode =3D TYPE_MODE (itype); > + tree scalar_type =3D build_nonstandard_integer_type ( > + GET_MODE_BITSIZE (mode).to_constant (), TYPE_UNSIGNED (itype)); > + pattern_stmt > + =3D gimple_build_assign (vect_recog_temp_ssa_var (scalar_type, = NULL), > + CONVERT_EXPR, var); > + } > + break; > + > case BIT_NOT_EXPR: > irhs1 =3D *defs.get (rhs1); > itype =3D TREE_TYPE (irhs1); >=20 >=