public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10764] tree-optimization/105368 - avoid overflow in powi_cost Date: Fri, 27 May 2022 13:15:17 +0000 (GMT) [thread overview] Message-ID: <20220527131517.3F7CC395B416@sourceware.org> (raw) https://gcc.gnu.org/g:ebe6ffee1aa2d819e4fbdf4130e054a33c274b38 commit r10-10764-gebe6ffee1aa2d819e4fbdf4130e054a33c274b38 Author: Richard Biener <rguenther@suse.de> Date: Mon Apr 25 10:55:21 2022 +0200 tree-optimization/105368 - avoid overflow in powi_cost The following avoids undefined signed overflow when computing the absolute of the exponent in powi_cost. 2022-04-25 Richard Biener <rguenther@suse.de> PR tree-optimization/105368 * tree-ssa-math-opts.c (powi_cost): Use absu_hwi. (cherry picked from commit f0e170f72f8bfaa2a64e1d09ebdfd48f917420f1) Diff: --- gcc/tree-ssa-math-opts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 4c89fddcfc5..fbaa3deffe3 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -1328,7 +1328,7 @@ powi_cost (HOST_WIDE_INT n) return 0; /* Ignore the reciprocal when calculating the cost. */ - val = (n < 0) ? -n : n; + val = absu_hwi (n); /* Initialize the exponent cache. */ memset (cache, 0, POWI_TABLE_SIZE * sizeof (bool));
reply other threads:[~2022-05-27 13:15 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220527131517.3F7CC395B416@sourceware.org \ --to=rguenth@gcc.gnu.org \ --cc=gcc-cvs@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).