From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A87CB3854834; Wed, 11 Aug 2021 07:22:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A87CB3854834 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101856] New: match_arith_overflow checks only mulv4_optab/umulv4_optab tables when smul_highpart_optab/umul_highpart_optab can produce decent code too Date: Wed, 11 Aug 2021 07:22:15 +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: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia 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 keywords bug_severity priority component assigned_to reporter target_milestone cf_gcctarget 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: Wed, 11 Aug 2021 07:22:15 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101856 Bug ID: 101856 Summary: match_arith_overflow checks only mulv4_optab/umulv4_optab tables when smul_highpart_optab/umul_highpart_optab can produce decent code too Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Target: aarch64-linux-gnu While looking at 30314, I Noticed aarch64 was not producing MUL_OVERFLOW for that test. I tested __builtin_umulll_overflow manually and got: umulh x8, x1, x0 cbz x8,=20 Which is what I had expected. Original testcase: typedef __SIZE_TYPE__ size_t; extern void *malloc(size_t), abort(void); void *allocate(size_t num, size_t size) { size_t total =3D num * size; if (total / size !=3D num) abort(); /* call malloc, whatever */ return 0; } The code does: || (code =3D=3D MULT_EXPR && optab_handler (cast_stmt ? mulv4_optab : umulv4_optab, TYPE_MODE (type)) =3D=3D CODE_FOR_nothing)) Oh it seems like there could be caching of reading optab_handler in match_arith_overflow too.=