public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102951] failure to optimize MIN_EXPR of subobject addresses of the same object Date: Tue, 26 Oct 2021 16:49:51 +0000 [thread overview] Message-ID: <bug-102951-4-X0szdQ7aSa@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-102951-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102951 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- extern int a[]; int * foo (void) { int *p1 = &a[1]; int *p2 = &a[2]; return p1 < p2 ? p1 : p2; } int bar (void) { int *p1 = &a[1]; int *p2 = &a[2]; return p1 < p2; } For the latter function, we optimize it in match.pd: /* When the addresses are not directly of decls compare base and offset. This implements some remaining parts of fold_comparison address comparisons but still no complete part of it. Still it is good enough to make fold_stmt not regress when not dispatching to fold_binary. */ (for cmp (simple_comparison) (simplify (cmp (convert1?@2 addr@0) (convert2? addr@1)) (with { poly_int64 off0, off1; ... So, I guess for MIN_EXPR/MAX_EXPR with ADDR_EXPR operands, we can optimize it similarly, the question is if we should try to do that through repeating that huge code from there, or try to outline big parts of that into a helper function, or perhaps could we e.g. do (with { #if GENERIC tree l = generic_simplify (..., LT_EXPR, ...); #else tree l = gimple_simplify (..., LT_EXPR, ...); #endif } (if (l && integer_zerop (l)) @0) (if (l && integer_nonzerop (l)) @1))) or so? and therefore try to fold LT_EXPR instead of MIN_EXPR or MAX_EXPR and if that folds into integer_zerop or integer_nonzerop
next prev parent reply other threads:[~2021-10-26 16:49 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-26 15:24 [Bug tree-optimization/102951] New: " msebor at gcc dot gnu.org 2021-10-26 16:49 ` jakub at gcc dot gnu.org [this message] 2021-10-27 2:43 ` [Bug tree-optimization/102951] " pinskia at gcc dot gnu.org 2021-10-27 6:56 ` rguenth at gcc dot gnu.org 2021-10-27 10:37 ` jakub at gcc dot gnu.org 2021-10-28 18:11 ` cvs-commit 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-102951-4-X0szdQ7aSa@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).