public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug middle-end/44608] New: unspecified signed overflow applied to unsigned int @ 2010-06-21 11:24 avr at gjlay dot de 2010-06-21 11:27 ` [Bug middle-end/44608] " avr at gjlay dot de ` (7 more replies) 0 siblings, 8 replies; 9+ messages in thread From: avr at gjlay dot de @ 2010-06-21 11:24 UTC (permalink / raw) To: gcc-bugs As discussed in http://gcc.gnu.org/ml/gcc-help/2010-06/msg00191.html I am filing a PR for the following piece of C: int abssat2 (int x) { unsigned int y = x; if (x < 0) y = -y; if (y >= 0x80000000) y--; return y; } Code looks fine until pass CE1 which introduces ABS rtx for the first comparison (ifcvt.c:noce_try_abs). Pass insn combine then calls combine.c:combine_simplify_rtx() which calls simplify_rtx.c:simplify_relational_operation (code=LT, mode=SImode, cmp_mode=SImode, op0=(abs:SI (reg:SI)), op1=(const_int 0)) and the latter removes the second comparison against 0x80000000. As this problem occurs on a non-standard target, let me know if I con you provide with any additional information. -- Summary: unspecified signed overflow applied to unsigned int Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: avr at gjlay dot de GCC build triplet: pc-linux GCC host triplet: pc-linux GCC target triplet: private http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44608 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/44608] unspecified signed overflow applied to unsigned int 2010-06-21 11:24 [Bug middle-end/44608] New: unspecified signed overflow applied to unsigned int avr at gjlay dot de @ 2010-06-21 11:27 ` avr at gjlay dot de 2010-06-21 11:28 ` avr at gjlay dot de ` (6 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: avr at gjlay dot de @ 2010-06-21 11:27 UTC (permalink / raw) To: gcc-bugs ------- Comment #1 from avr at gjlay dot de 2010-06-21 11:26 ------- Created an attachment (id=20955) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20955&action=view) Dump for .c.123t.optimized Dump for .c.123t.optimized -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44608 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/44608] unspecified signed overflow applied to unsigned int 2010-06-21 11:24 [Bug middle-end/44608] New: unspecified signed overflow applied to unsigned int avr at gjlay dot de 2010-06-21 11:27 ` [Bug middle-end/44608] " avr at gjlay dot de @ 2010-06-21 11:28 ` avr at gjlay dot de 2010-06-21 11:29 ` avr at gjlay dot de ` (5 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: avr at gjlay dot de @ 2010-06-21 11:28 UTC (permalink / raw) To: gcc-bugs ------- Comment #2 from avr at gjlay dot de 2010-06-21 11:28 ------- Created an attachment (id=20956) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20956&action=view) Dump for .c.128r.expand Dump for .c.128r.expand -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44608 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/44608] unspecified signed overflow applied to unsigned int 2010-06-21 11:24 [Bug middle-end/44608] New: unspecified signed overflow applied to unsigned int avr at gjlay dot de 2010-06-21 11:27 ` [Bug middle-end/44608] " avr at gjlay dot de 2010-06-21 11:28 ` avr at gjlay dot de @ 2010-06-21 11:29 ` avr at gjlay dot de 2010-06-21 11:30 ` avr at gjlay dot de ` (4 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: avr at gjlay dot de @ 2010-06-21 11:29 UTC (permalink / raw) To: gcc-bugs ------- Comment #3 from avr at gjlay dot de 2010-06-21 11:28 ------- Created an attachment (id=20957) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20957&action=view) Dump for .c.141r.ce1 Dump for .c.141r.ce1 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44608 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/44608] unspecified signed overflow applied to unsigned int 2010-06-21 11:24 [Bug middle-end/44608] New: unspecified signed overflow applied to unsigned int avr at gjlay dot de ` (2 preceding siblings ...) 2010-06-21 11:29 ` avr at gjlay dot de @ 2010-06-21 11:30 ` avr at gjlay dot de 2010-06-21 11:38 ` rguenth at gcc dot gnu dot org ` (3 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: avr at gjlay dot de @ 2010-06-21 11:30 UTC (permalink / raw) To: gcc-bugs ------- Comment #4 from avr at gjlay dot de 2010-06-21 11:30 ------- Created an attachment (id=20958) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20958&action=view) Dump for .c.159r.combine Dump for .c.159r.combine -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44608 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/44608] unspecified signed overflow applied to unsigned int 2010-06-21 11:24 [Bug middle-end/44608] New: unspecified signed overflow applied to unsigned int avr at gjlay dot de ` (3 preceding siblings ...) 2010-06-21 11:30 ` avr at gjlay dot de @ 2010-06-21 11:38 ` rguenth at gcc dot gnu dot org 2010-06-21 11:51 ` rguenth at gcc dot gnu dot org ` (2 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: rguenth at gcc dot gnu dot org @ 2010-06-21 11:38 UTC (permalink / raw) To: gcc-bugs ------- Comment #5 from rguenth at gcc dot gnu dot org 2010-06-21 11:38 ------- It is folding from the frontend that changes if (y >= 0x80000000) to if ((int) y < 0) (see code == LT instead of code == GEU) But the main issue is that y = -y to abs is bogus (but we can't easily tell that as on RTL operands do not have a signedness). -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Keywords| |wrong-code Last reconfirmed|0000-00-00 00:00:00 |2010-06-21 11:38:28 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44608 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/44608] unspecified signed overflow applied to unsigned int 2010-06-21 11:24 [Bug middle-end/44608] New: unspecified signed overflow applied to unsigned int avr at gjlay dot de ` (4 preceding siblings ...) 2010-06-21 11:38 ` rguenth at gcc dot gnu dot org @ 2010-06-21 11:51 ` rguenth at gcc dot gnu dot org 2010-06-21 12:27 ` avr at gjlay dot de 2010-07-21 22:51 ` pinskia at gcc dot gnu dot org 7 siblings, 0 replies; 9+ messages in thread From: rguenth at gcc dot gnu dot org @ 2010-06-21 11:51 UTC (permalink / raw) To: gcc-bugs ------- Comment #6 from rguenth at gcc dot gnu dot org 2010-06-21 11:50 ------- int __attribute__((noinline)) abssat2 (int x) { unsigned int y = x; if (x < 0) y = -y; if (y >= 0x80000000) y--; return y; } extern void abort (void); int main() { if (abssat2 (0x80000000) != 0x7fffffff) abort (); return 0; } does not fail on x86_64 or i?86. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44608 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/44608] unspecified signed overflow applied to unsigned int 2010-06-21 11:24 [Bug middle-end/44608] New: unspecified signed overflow applied to unsigned int avr at gjlay dot de ` (5 preceding siblings ...) 2010-06-21 11:51 ` rguenth at gcc dot gnu dot org @ 2010-06-21 12:27 ` avr at gjlay dot de 2010-07-21 22:51 ` pinskia at gcc dot gnu dot org 7 siblings, 0 replies; 9+ messages in thread From: avr at gjlay dot de @ 2010-06-21 12:27 UTC (permalink / raw) To: gcc-bugs ------- Comment #7 from avr at gjlay dot de 2010-06-21 12:27 ------- (In reply to comment #5) > It is folding from the frontend that changes > > if (y >= 0x80000000) > > to > > if ((int) y < 0) > > (see code == LT instead of code == GEU) > > But the main issue is that y = -y to abs is bogus (but we can't easily tell > that as on RTL operands do not have a signedness). Both transformation are ok from the target's point of view. The bad thing is that undefinedness is propagated to RTL which is supposed to be an algebraic formulation of the target's instruction set. But in this case RTL is treated like a low level representation of C (or any other language gcc supports). To reproduce the problem it seems essential that there is an abssi2 insn in the md. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44608 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/44608] unspecified signed overflow applied to unsigned int 2010-06-21 11:24 [Bug middle-end/44608] New: unspecified signed overflow applied to unsigned int avr at gjlay dot de ` (6 preceding siblings ...) 2010-06-21 12:27 ` avr at gjlay dot de @ 2010-07-21 22:51 ` pinskia at gcc dot gnu dot org 7 siblings, 0 replies; 9+ messages in thread From: pinskia at gcc dot gnu dot org @ 2010-07-21 22:51 UTC (permalink / raw) To: gcc-bugs ------- Comment #8 from pinskia at gcc dot gnu dot org 2010-07-21 22:51 ------- For some reason rs6000 has an abssi pattern but it is not produced by ce1. -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- GCC build triplet|pc-linux | GCC host triplet|pc-linux | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44608 ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-07-21 22:51 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-06-21 11:24 [Bug middle-end/44608] New: unspecified signed overflow applied to unsigned int avr at gjlay dot de 2010-06-21 11:27 ` [Bug middle-end/44608] " avr at gjlay dot de 2010-06-21 11:28 ` avr at gjlay dot de 2010-06-21 11:29 ` avr at gjlay dot de 2010-06-21 11:30 ` avr at gjlay dot de 2010-06-21 11:38 ` rguenth at gcc dot gnu dot org 2010-06-21 11:51 ` rguenth at gcc dot gnu dot org 2010-06-21 12:27 ` avr at gjlay dot de 2010-07-21 22:51 ` pinskia at gcc dot gnu dot org
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).