aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-10-15 09:10:40 +0200
committerRichard Biener <rguenther@suse.de>2020-10-15 10:54:24 +0200
commit28290cb50c7dbf87458befeb3e295b5cb13560b5 (patch)
tree5ddc99caf2358cf5ec76d0136e54f00256b62430 /gcc/fold-const.c
parentee21a5f3979adab95069f363b078812a54c5b59f (diff)
downloadgcc-28290cb50c7dbf87458befeb3e295b5cb13560b5.zip
gcc-28290cb50c7dbf87458befeb3e295b5cb13560b5.tar.gz
gcc-28290cb50c7dbf87458befeb3e295b5cb13560b5.tar.bz2
tree-optimization/97482 - fix split_constant_offset of nop-conversions
split_constant_offset is confused about a nop-conversion from unsigned long to sizetype and tries to prove non-overflowing of the inner operation. Obviously the conversion could have been elided so make sure split_constant_offset handles this properly. It also makes sure that convert_to_ptrofftype does not introduce conversions not necessary which in this case is the source for the unnecessary conversion. 2020-10-15 Richard Biener <rguenther@suse.de> PR tree-optimization/97482 * tree-data-ref.c (split_constant_offset_1): Handle trivial conversions better. * fold-const.c (convert_to_ptrofftype_loc): Elide conversion if the offset is already ptrofftype_p. * gcc.dg/vect/pr97428.c: New testcase.
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 0cc80ad..ebd32bb 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -15489,6 +15489,8 @@ ptr_difference_const (tree e1, tree e2, poly_int64_pod *diff)
tree
convert_to_ptrofftype_loc (location_t loc, tree off)
{
+ if (ptrofftype_p (TREE_TYPE (off)))
+ return off;
return fold_convert_loc (loc, sizetype, off);
}