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 middle-end/111845] [14 regression] ICE when building pycryptodome
Date: Tue, 17 Oct 2023 11:37:27 +0000	[thread overview]
Message-ID: <bug-111845-4-uLzVmen1ss@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111845-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111845

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Same with renamed vars, so that the long variable names don't make it
unreadable:

int a, b;
unsigned int c, d, e;

void
foo (int x)
{
  b += d;
  c += b < d;
  b += e = a < x;
  c += b;
  c += b < e;
}

I believe the above is equivalent to:
  e = a < x;
  unsigned c1;
  b = __builtin_addc (b, d, e, &c1);
  c = __builtin_addc (c, b, c1, &c1);
i.e. b is set to b + d + e where e is in [0, 1] range and c is set to c + b +
carry-out
from the b + d + e additions.

match_uaddc_usubc is called on the _17 = _30 + _31; addition in:
b.0_1 = b;
b.1_2 = (unsigned int) b.0_1;
d.2_3 = d;
_8 = .ADD_OVERFLOW (b.1_2, d.2_3);
_4 = REALPART_EXPR <_8>;
_14 = IMAGPART_EXPR <_8>;
_5 = _14 != 0;
_6 = (unsigned int) _5;
c.6_7 = c;
_31 = _6 + c.6_7;
a.7_9 = a;
_10 = a.7_9 < x_19(D);
_11 = (unsigned int) _10;
e = _11;
_29 = .ADD_OVERFLOW (_4, _11);
_12 = REALPART_EXPR <_29>;
_28 = IMAGPART_EXPR <_29>;
_13 = (int) _12;
b = _13;
_15 = _28 != 0;
_16 = (unsigned int) _15;
_30 = _12 + _16;
_17 = _30 + _31;
c = _17;
return;
and changes it:
@@ -12,14 +12,14 @@ a.7_9 = a;
 _10 = a.7_9 < x_19(D);
 _11 = (unsigned int) _10;
 e = _11;
+_27 = .UADDC (b.1_2, d.2_3, _11);
 _29 = .ADD_OVERFLOW (_4, _11);
-_12 = REALPART_EXPR <_29>;
-_28 = IMAGPART_EXPR <_29>;
+_12 = REALPART_EXPR <_27>;
 _13 = (int) _12;
 b = _13;
-_15 = _28 != 0;
-_16 = (unsigned int) _15;
 _30 = _12 + _16;
-_17 = _30 + _31;
+_26 = IMAGPART_EXPR <_27>;
+_25 = .UADDC (c.6_7, _12, _26);
+_17 = REALPART_EXPR <_25>;
 c = _17;
 return;
That again looks correct to me, except that the dead _30 = _12 + _16 statement
should have been removed as well but wasn't.  The bb contains still other dead
statements
but the _30 = _12 + _16; is the only problematic one, as it refers to released
SSA_NAME.  After a fast DCE I think the bb would turn into:
b.0_1 = b;
b.1_2 = (unsigned int) b.0_1;
d.2_3 = d;
c.6_7 = c;
a.7_9 = a;
_10 = a.7_9 < x_19(D);
_11 = (unsigned int) _10;
e = _11;
_27 = .UADDC (b.1_2, d.2_3, _11);
_12 = REALPART_EXPR <_27>;
_13 = (int) _12;
b = _13;
_26 = IMAGPART_EXPR <_27>;
_25 = .UADDC (c.6_7, _12, _26);
_17 = REALPART_EXPR <_25>;
c = _17;
return;

  parent reply	other threads:[~2023-10-17 11:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-17  5:09 [Bug middle-end/111845] New: " sjames at gcc dot gnu.org
2023-10-17  5:27 ` [Bug middle-end/111845] " pinskia at gcc dot gnu.org
2023-10-17  5:37 ` pinskia at gcc dot gnu.org
2023-10-17  5:42 ` pinskia at gcc dot gnu.org
2023-10-17  5:46 ` sjames at gcc dot gnu.org
2023-10-17  5:50 ` sjames at gcc dot gnu.org
2023-10-17  5:52 ` pinskia at gcc dot gnu.org
2023-10-17  6:56 ` rguenth at gcc dot gnu.org
2023-10-17 11:37 ` jakub at gcc dot gnu.org [this message]
2023-10-17 13:46 ` [Bug middle-end/111845] [14 regression] ICE when building pycryptodome since r14-1837-g43a3252c42af12 sjames at gcc dot gnu.org
2023-10-17 14:18 ` jakub at gcc dot gnu.org
2023-10-18 10:38 ` cvs-commit at gcc dot gnu.org
2023-10-18 10:39 ` jakub at gcc dot gnu.org
2023-10-18 10:47 ` sjames 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-111845-4-uLzVmen1ss@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: link
Be 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).