aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2024-07-03 09:30:28 +0100
committerTamar Christina <tamar.christina@arm.com>2024-07-03 09:30:28 +0100
commit25127123100f04c2d5d70c6933a5f5aedcd69c40 (patch)
tree285bea41b370bb5de6c0c26a603460d50f8fa96e /gcc
parent47ea6bddd15a568cedc5d7026d2cc9d5599e6e01 (diff)
downloadgcc-25127123100f04c2d5d70c6933a5f5aedcd69c40.zip
gcc-25127123100f04c2d5d70c6933a5f5aedcd69c40.tar.gz
gcc-25127123100f04c2d5d70c6933a5f5aedcd69c40.tar.bz2
ivopts: fix wide_int_constant_multiple_p when VAL and DIV are 0. [PR114932]
wide_int_constant_multiple_p tries to check if for two tree expressions a and b that there is a multiplier which makes a == b * c. This code however seems to think that there's no c where a=0 and b=0 are equal which is of course wrong. This fixes it and also fixes the comment. gcc/ChangeLog: PR tree-optimization/114932 * tree-affine.cc (wide_int_constant_multiple_p): Support 0 and 0 being multiples.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/tree-affine.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/gcc/tree-affine.cc b/gcc/tree-affine.cc
index d6309c4..76117aa 100644
--- a/gcc/tree-affine.cc
+++ b/gcc/tree-affine.cc
@@ -880,11 +880,11 @@ free_affine_expand_cache (hash_map<tree, name_expansion *> **cache)
*cache = NULL;
}
-/* If VAL != CST * DIV for any constant CST, returns false.
- Otherwise, if *MULT_SET is true, additionally compares CST and MULT,
- and if they are different, returns false. Finally, if neither of these
- two cases occur, true is returned, and CST is stored to MULT and MULT_SET
- is set to true. */
+/* If VAL == CST * DIV for any constant CST, returns true.
+ and if *MULT_SET is true, additionally compares CST and MULT
+ and if they are different, returns false. If true is returned, CST is
+ stored to MULT and MULT_SET is set to true unless VAL and DIV are both zero
+ in which case neither MULT nor MULT_SET are updated. */
static bool
wide_int_constant_multiple_p (const poly_widest_int &val,
@@ -895,6 +895,9 @@ wide_int_constant_multiple_p (const poly_widest_int &val,
if (known_eq (val, 0))
{
+ if (known_eq (div, 0))
+ return true;
+
if (*mult_set && maybe_ne (*mult, 0))
return false;
*mult_set = true;