From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 954723857C68; Wed, 10 Aug 2022 06:03:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 954723857C68 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106322] [12/13 Regression] tree-vectorize: Wrong code at O2 level (-fno-tree-vectorize is working) since r12-2404-ga1d27560770818c5 Date: Wed, 10 Aug 2022 06:03:50 +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.1.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: linkw at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.2 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, 10 Aug 2022 06:03:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106322 --- Comment #39 from Andrew Pinski --- Comment on attachment 53428 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D53428 untested patch >diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc >index d666ccccf67..7d8b4ac2200 100644 >--- a/gcc/internal-fn.cc >+++ b/gcc/internal-fn.cc >@@ -3750,7 +3750,12 @@ static bool > direct_optab_supported_p (direct_optab optab, tree_pair types, > optimization_type opt_type) > { >- machine_mode mode =3D TYPE_MODE (types.first); >+ tree type =3D types.first; >+ machine_mode mode =3D TYPE_MODE (type); >+ /* Scalar mode optab can't work for vector type, return false if >+ the given type is vector type but the mode isn't vector mode. */ >+ if (VECTOR_TYPE_P (type) !=3D VECTOR_MODE_P (mode)) >+ return false; There are a few which scalar mode and vector types can differ and still wor= k: IOR, XOR, and AND. I wonder if those should be special cased here or somewh= ere else. > gcc_checking_assert (mode =3D=3D TYPE_MODE (types.second)); > return direct_optab_handler (optab, mode, opt_type) !=3D CODE_FOR_nothi= ng; > } >@@ -3763,6 +3768,12 @@ static bool > convert_optab_supported_p (convert_optab optab, tree_pair types, > optimization_type opt_type) > { >+ tree type =3D types.first; >+ machine_mode mode =3D TYPE_MODE (type); >+ /* Scalar mode optab can't work for vector type, return false if >+ the given type is vector type but the mode isn't vector mode. */ >+ if (VECTOR_TYPE_P (type) !=3D VECTOR_MODE_P (mode)) >+ return false; > return (convert_optab_handler (optab, TYPE_MODE (types.first), > TYPE_MODE (types.second), opt_type) > !=3D CODE_FOR_nothing); >@@ -3778,6 +3789,7 @@ multi_vector_optab_supported_p (convert_optab optab,= tree_pair types, > gcc_assert (TREE_CODE (types.first) =3D=3D ARRAY_TYPE); > machine_mode imode =3D TYPE_MODE (types.first); > machine_mode vmode =3D TYPE_MODE (TREE_TYPE (types.first)); >+ gcc_assert (VECTOR_MODE_P (vmode)); > return (convert_optab_handler (optab, imode, vmode, opt_type) > !=3D CODE_FOR_nothing); > }=