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/111445] [12/13/14 Regression] Wrong code at -Os on x86_64-linux-gnu since r12-1077-g57bf3751511 Date: Fri, 20 Oct 2023 13:08:32 +0000 [thread overview] Message-ID: <bug-111445-4-kzR0J54h8j@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-111445-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111445 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org --- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- And I think its a SCEV/tree-affine issue. We have <bb 6> [local count: 236223200]: # e_15 = PHI <0(10), e_21(5)> _9 = (unsigned char) d_26; _10 = _9 + 1; _11 = (int) _10; _12 = (int) e_15; _13 = _11 + _12; if (_13 <= 1) goto <bb 5>; [50.00%] else goto <bb 7>; [50.00%] <bb 5> [local count: 118111600]: b.6_7 = b; _8 = (int) b.6_7; check (_8); e_21 = e_15 + 1; goto <bb 6>; (get_scalar_evolution (scalar = e_15) (scalar_evolution = {0, +, 1}_2)) that's OK if the niter bound is correct (get_scalar_evolution (scalar = _12) (scalar_evolution = {0, +, 1}_2)) likewise (get_scalar_evolution (scalar = _13) (scalar_evolution = {(int) ((unsigned char) d_26 + 1), +, 1}_2)) also OK. But from that we get IV struct: SSA_NAME: _13 Type: int Base: d_26 + 1 Step: 1 Biv: N Overflowness wrto loop niter: No-overflow That's because simple_iv_with_niters does, getting the correct iv->base (int) ((unsigned char) d_26 + 1) /* Try to simplify iv base: (signed T) ((unsigned T)base + step) ;; TREE_TYPE (base) == signed T == (signed T)(unsigned T)base + step == base + step If we can prove operation (base + step) doesn't overflow or underflow. Specifically, we try to prove below conditions are satisfied: base <= UPPER_BOUND (type) - step ;;step > 0 base >= LOWER_BOUND (type) - step ;;step < 0 This is done by proving the reverse conditions are false using loop's initial conditions. The is necessary to make loop niter, or iv overflow analysis easier for below example: int foo (int *a, signed char s, signed char l) { signed char i; for (i = s; i < l; i++) a[i] = 0; return 0; } Note variable I is firstly converted to type unsigned char, incremented, then converted back to type signed char. */ where we end up querying d_26 > 2147483646 but the comment also doesn't match us skipping a narrowing conversion here (besides failing to use the limit based on the narrowed type).
next prev parent reply other threads:[~2023-10-20 13:08 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-17 13:21 [Bug tree-optimization/111445] New: " shaohua.li at inf dot ethz.ch 2023-09-17 16:12 ` [Bug tree-optimization/111445] [12/13/14 Regression] " pinskia at gcc dot gnu.org 2023-09-18 9:14 ` rguenth at gcc dot gnu.org 2023-10-20 12:04 ` rguenth at gcc dot gnu.org 2023-10-20 12:36 ` rguenth at gcc dot gnu.org 2023-10-20 13:08 ` rguenth at gcc dot gnu.org [this message] 2023-10-20 13:53 ` cvs-commit at gcc dot gnu.org 2023-10-20 13:54 ` [Bug tree-optimization/111445] [12/13 " rguenth at gcc dot gnu.org 2023-11-10 14:24 ` cvs-commit at gcc dot gnu.org 2023-11-14 14:20 ` [Bug tree-optimization/111445] [12 " rguenth at gcc dot gnu.org 2023-11-27 13:09 ` cvs-commit at gcc dot gnu.org 2023-11-27 13:10 ` rguenth at gcc dot gnu.org 2024-06-21 9:22 ` 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-111445-4-kzR0J54h8j@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).