public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/45034] [4.3/4.4/4.5/4.6 Regression] "safe" conversion from unsigned to signed char gives broken code Date: Wed, 28 Jul 2010 09:32:00 -0000 [thread overview] Message-ID: <20100728093209.19928.qmail@sourceware.org> (raw) In-Reply-To: <bug-45034-7665@http.gcc.gnu.org/bugzilla/> ------- Comment #11 from rguenth at gcc dot gnu dot org 2010-07-28 09:32 ------- I suppose that uy = -ux; is really uy = (unsigned char) -(int) ux; as unsigned char promotes to int. We then incorrectly narrow this to -(signed char) ux. We do this again in convert_to_integer. Our bag of premature (and bogus) optimizations. case NEGATE_EXPR: case BIT_NOT_EXPR: /* This is not correct for ABS_EXPR, since we must test the sign before truncation. */ { tree typex; /* Don't do unsigned arithmetic where signed was wanted, or vice versa. */ if (TYPE_UNSIGNED (TREE_TYPE (expr))) typex = unsigned_type_for (type); else typex = signed_type_for (type); return convert (type, fold_build1 (ex_form, typex, convert (typex, TREE_OPERAND (expr, 0)))); well - I have no idea why we can't always choose an unsigned type here (testing that now). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45034
next prev parent reply other threads:[~2010-07-28 9:32 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-07-22 21:13 [Bug c/45034] New: " mikpe at it dot uu dot se 2010-07-22 21:14 ` [Bug c/45034] " mikpe at it dot uu dot se 2010-07-22 21:26 ` [Bug tree-optimization/45034] " pinskia at gcc dot gnu dot org 2010-07-23 4:14 ` hjl dot tools at gmail dot com 2010-07-23 8:52 ` [Bug tree-optimization/45034] [4.3/4.4/4.5/4.6 Regression] " rguenth at gcc dot gnu dot org 2010-07-24 18:47 ` mikpe at it dot uu dot se 2010-07-25 10:56 ` mikpe at it dot uu dot se 2010-07-26 14:47 ` rakdver at gcc dot gnu dot org 2010-07-27 22:18 ` mikpe at it dot uu dot se 2010-07-27 22:43 ` joseph at codesourcery dot com 2010-07-27 23:09 ` rakdver at kam dot mff dot cuni dot cz 2010-07-28 9:32 ` rguenth at gcc dot gnu dot org [this message] 2010-07-28 12:24 ` rguenth at gcc dot gnu dot org 2010-07-28 14:14 ` mikpe at it dot uu dot se 2010-07-28 15:38 ` mikpe at it dot uu dot se 2010-07-28 23:32 ` mikpe at it dot uu dot se 2010-07-29 11:00 ` [Bug tree-optimization/45034] [4.3/4.4/4.5 " rguenth at gcc dot gnu dot org 2010-07-29 11:00 ` [Bug tree-optimization/45034] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org 2010-08-08 15:50 ` [Bug tree-optimization/45034] [4.3/4.4/4.5 " rguenth at gcc dot gnu dot org 2010-08-08 15:51 ` [Bug tree-optimization/45034] [4.3/4.4 " rguenth at gcc dot gnu dot 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=20100728093209.19928.qmail@sourceware.org \ --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).