From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 488E7385DC39; Fri, 6 Aug 2021 10:26:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 488E7385DC39 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101801] New: vect_worthwhile_without_simd_p is broken Date: Fri, 06 Aug 2021 10:26:09 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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: Fri, 06 Aug 2021 10:26:09 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101801 Bug ID: 101801 Summary: vect_worthwhile_without_simd_p is broken Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- vect_worthwhile_without_simd_p is currently bool vect_worthwhile_without_simd_p (vec_info *vinfo, tree_code code) { loop_vec_info loop_vinfo =3D dyn_cast (vinfo); unsigned HOST_WIDE_INT value; return (loop_vinfo && LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant (&value) && value >=3D vect_min_worthwhile_factor (code)); } which means it's never worthwhile to BB vectorize. Also the VF check doesn't honor SLP so that a fully SLPed loop with VF =3D=3D 1 is never considered worthwhile to vectorize. I ran into this beast when looking at vectorization of mask condition operations like cond_mask1 & cond_mask2 which, for AVX512, have integer mode but vectorizable_operation does /* Worthwhile without SIMD support? Check only during analysis. */ if (!VECTOR_MODE_P (vec_mode) && !vec_stmt && !vect_worthwhile_without_simd_p (vinfo, code)) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, "not worthwhile without SIMD support.\n"); return false; } and in my case with SLP the VF was indeed one and vectorization failed. I think the code should not look at the vectorization factor but instead at the vector type (and its number of components).=