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/60930] [4.8/4.9/4.10 Regression] Wrong folding of - ((unsigned long long) a * (unsigned long long) (unsigned int)-1) Date: Thu, 24 Apr 2014 09:16:00 -0000 [thread overview] Message-ID: <bug-60930-4-bq7Wq0DulV@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-60930-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60930 --- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- I think the problem is that we look at expressions in 'long unsigned int' but a base_cand of type 'int'. That is, the bug in the computation is that ctype is unsigned long but stride is int. If that is really desired and required then you want to do sth more like Index: gcc/gimple-ssa-strength-reduction.c =================================================================== --- gcc/gimple-ssa-strength-reduction.c (revision 209677) +++ gcc/gimple-ssa-strength-reduction.c (working copy) @@ -1114,15 +1114,20 @@ create_mul_imm_cand (gimple gs, tree bas X = Y * c ============================ X = (B + i') * (S * c) */ - base = base_cand->base_expr; - index = base_cand->index; temp = tree_to_double_int (base_cand->stride) * tree_to_double_int (stride_in); - stride = double_int_to_tree (TREE_TYPE (stride_in), temp); - ctype = base_cand->cand_type; - if (has_single_use (base_in)) - savings = (base_cand->dead_savings - + stmt_cost (base_cand->cand_stmt, speed)); + temp = temp.ext (TYPE_PRECISION (base_cand->cand_type), + TYPE_UNSIGNED (base_cand->cand_type)); + if (double_int_fits_to_tree_p (TREE_TYPE (stride_in), temp)) + { + base = base_cand->base_expr; + index = base_cand->index; + stride = double_int_to_tree (TREE_TYPE (stride_in), temp); + ctype = base_cand->cand_type; + if (has_single_use (base_in)) + savings = (base_cand->dead_savings + + stmt_cost (base_cand->cand_stmt, speed)); + } } else if (base_cand->kind == CAND_ADD && integer_onep (base_cand->stride)) { as I suppose a truncation to ctype will happen anyway (and is ok).
next prev parent reply other threads:[~2014-04-24 9:16 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-04-23 2:24 [Bug tree-optimization/60930] New: Wrong constant folding ishiura-compiler at ml dot kwansei.ac.jp 2014-04-23 2:44 ` [Bug tree-optimization/60930] Wrong folding of - ((unsigned long long) a * (unsigned long long) (unsigned int)-1) pinskia at gcc dot gnu.org 2014-04-23 6:55 ` [Bug tree-optimization/60930] [4.8/4.9/4.10 Regression] " jakub at gcc dot gnu.org 2014-04-23 8:39 ` rguenth at gcc dot gnu.org 2014-04-23 12:36 ` wschmidt at gcc dot gnu.org 2014-04-23 21:04 ` wschmidt at gcc dot gnu.org 2014-04-23 21:22 ` jakub at gcc dot gnu.org 2014-04-23 22:10 ` wschmidt at gcc dot gnu.org 2014-04-24 9:16 ` rguenth at gcc dot gnu.org [this message] 2014-04-24 14:41 ` wschmidt at gcc dot gnu.org 2014-04-24 15:40 ` wschmidt at gcc dot gnu.org 2014-04-24 16:00 ` wschmidt at gcc dot gnu.org 2014-04-25 14:54 ` wschmidt at gcc dot gnu.org 2014-05-02 21:50 ` wschmidt at gcc dot gnu.org 2014-05-02 21:51 ` wschmidt at gcc dot gnu.org 2014-05-02 21:53 ` wschmidt 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-60930-4-bq7Wq0DulV@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).