public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109791] -Wstringop-overflow warning with -O3 and _GLIBCXX_USE_CXX11_ABI=0 Date: Thu, 11 May 2023 12:22:10 +0000 [thread overview] Message-ID: <bug-109791-4-bQrrIdzwu8@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-109791-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109791 --- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> --- So the first pass that makes things difficult is reassoc which transforms _51 = (unsigned long) &MEM <char[3]> [(void *)&str + 2B]; _4 = (unsigned long) __i_44; _65 = _51 - _4; _48 = _65 + 18446744073709551615; _46 = _48 > 13; if (_46 != 0) to _51 = (unsigned long) &MEM <char[3]> [(void *)&str + 2B]; _4 = (unsigned long) __i_44; _12 = -_4; _119 = _51 + 18446744073709551615; _48 = _119 - _4; _46 = _48 > 13; if (_46 != 0) (also leaving garbage around). That's probably because of the PHI biasing and __i_44 being defined by a PHI. niter analysis produces # of iterations (((unsigned long) &MEM <char[3]> [(void *)&str + 2B] - (unsigned long) __i_44) + 18446744073709551615) / 2, bounded by 9223372036854775807 but doesn't expand __i_44 (not sure if we'd fold the thing then). The gimplifier folds stmts w/o following SSA edges when we eventually re-gimplify those expressions for insertion. If we expand offsetting of invariant bases we get instead # of iterations ((unsigned long) &MEM <char[3]> [(void *)&str + 2B] - (unsigned long) (&str + (_69 + 1))) / 2, bounded by 9223372036854775807 but that's still not simplified. I think ptr_difference_const should handle this - of course the difference here isn't const... /* Try folding difference of addresses. */ (simplify (minus (convert ADDR_EXPR@0) (convert @1)) (if (tree_nop_conversion_p (type, TREE_TYPE (@0))) (with { poly_int64 diff; } (if (ptr_difference_const (@0, @1, &diff)) { build_int_cst_type (type, diff); })))) (simplify (minus (convert @0) (convert ADDR_EXPR@1)) (if (tree_nop_conversion_p (type, TREE_TYPE (@0))) (with { poly_int64 diff; } (if (ptr_difference_const (@0, @1, &diff)) { build_int_cst_type (type, diff); })))) it works fine when adding (simplify (minus (convert ADDR_EXPR@0) (convert (pointer_plus @1 @2))) (if (tree_nop_conversion_p (type, TREE_TYPE (@0))) (with { poly_int64 diff; } (if (ptr_difference_const (@0, @1, &diff)) (minus { build_int_cst_type (type, diff); } (convert @2)))))) then we get # of iterations (1 - (unsigned long) _69) / 2, bounded by 9223372036854775807 and the diagnostic is gone.
next prev parent reply other threads:[~2023-05-11 12:22 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-09 16:48 [Bug c++/109791] New: " szhong at perforce dot com 2023-05-09 17:28 ` [Bug tree-optimization/109791] " pinskia at gcc dot gnu.org 2023-05-10 7:26 ` rguenth at gcc dot gnu.org 2023-05-11 8:05 ` aldyh at gcc dot gnu.org 2023-05-11 8:19 ` aldyh at gcc dot gnu.org 2023-05-11 9:39 ` rguenth at gcc dot gnu.org 2023-05-11 9:47 ` aldyh at gcc dot gnu.org 2023-05-11 11:36 ` rguenther at suse dot de 2023-05-11 11:40 ` rguenth at gcc dot gnu.org 2023-05-11 12:22 ` rguenth at gcc dot gnu.org [this message] 2023-05-11 12:34 ` rguenth at gcc dot gnu.org 2023-05-11 12:35 ` rguenth at gcc dot gnu.org 2023-05-11 12:36 ` rguenth at gcc dot gnu.org 2023-05-12 11:48 ` cvs-commit at gcc dot gnu.org 2023-05-25 12:14 ` rguenth at gcc dot gnu.org 2023-05-25 12:15 ` rguenth at gcc dot gnu.org 2023-05-25 12:16 ` rguenth at gcc dot gnu.org 2023-05-25 15:35 ` pinskia at gcc dot gnu.org 2023-06-07 22:28 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-109791-4-bQrrIdzwu8@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).