From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B81DF3858D20; Wed, 23 Feb 2022 07:18:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B81DF3858D20 From: "linkw at gcc dot gnu.org" 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:18:17 +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: linkw at gcc dot gnu.org 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:18:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104595 --- Comment #8 from Kewen Lin --- I had one local hack and just found it can survive on x86 bootstrapping and regression testing. I guess maybe it's good to post here. Just ignore this = if it looks like noise. :) The point is to do the conversion for the loaded bo= ol value from memory, normally it should be like a nop, but for this test case= , it can help us to generate the expected char comparison. 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; + 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, tree out_type, SSA_NAME, irhs1); break; + 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, NU= LL), + CONVERT_EXPR, var); + } + break; + case BIT_NOT_EXPR: irhs1 =3D *defs.get (rhs1); itype =3D TREE_TYPE (irhs1);=