From 28290cb50c7dbf87458befeb3e295b5cb13560b5 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 15 Oct 2020 09:10:40 +0200 Subject: 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 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. --- gcc/tree-data-ref.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gcc/tree-data-ref.c') diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 5505ba4..3bf460c 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -754,7 +754,9 @@ split_constant_offset_1 (tree type, tree op0, enum tree_code code, tree op1, && TYPE_PRECISION (type) >= TYPE_PRECISION (itype) && (POINTER_TYPE_P (type) || INTEGRAL_TYPE_P (type))) { - if (INTEGRAL_TYPE_P (itype) && TYPE_OVERFLOW_WRAPS (itype)) + if (INTEGRAL_TYPE_P (itype) && TYPE_OVERFLOW_WRAPS (itype) + && (TYPE_PRECISION (type) > TYPE_PRECISION (itype) + || TYPE_UNSIGNED (itype) != TYPE_UNSIGNED (type))) { /* Split the unconverted operand and try to prove that wrapping isn't a problem. */ -- cgit v1.1