aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2022-04-25 10:55:21 +0200
committerRichard Biener <rguenther@suse.de>2022-04-25 11:46:59 +0200
commitf0e170f72f8bfaa2a64e1d09ebdfd48f917420f1 (patch)
tree259fc7afcfe8b3f9535c4ea8ef140185cb1aedac /gcc
parentab91c10792cd3a1ba1495aa30a34ca17b043bafb (diff)
downloadgcc-f0e170f72f8bfaa2a64e1d09ebdfd48f917420f1.zip
gcc-f0e170f72f8bfaa2a64e1d09ebdfd48f917420f1.tar.gz
gcc-f0e170f72f8bfaa2a64e1d09ebdfd48f917420f1.tar.bz2
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.cc (powi_cost): Use absu_hwi.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/tree-ssa-math-opts.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
index 102b7a2..7555793 100644
--- a/gcc/tree-ssa-math-opts.cc
+++ b/gcc/tree-ssa-math-opts.cc
@@ -1462,7 +1462,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));