[3/3] Less strip_offset in IVOPTs

Message ID 20230621113206.3F9773856973@sourceware.org
State Accepted
Headers
Series [1/3] Hide and refactor IVOPTs strip_offset |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Richard Biener June 21, 2023, 11:31 a.m. UTC
  This avoids one strip_offset use in add_iv_candidate_for_use where
we know it operates on a sizetype quantity.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	* tree-ssa-loop-ivopts.cc (add_iv_candidate_for_use): Use
	split_constant_offset for the POINTER_PLUS_EXPR case.
---
 gcc/tree-ssa-loop-ivopts.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc
index 65caf382bba..03161813e0a 100644
--- a/gcc/tree-ssa-loop-ivopts.cc
+++ b/gcc/tree-ssa-loop-ivopts.cc
@@ -3588,8 +3588,9 @@  add_iv_candidate_for_use (struct ivopts_data *data, struct iv_use *use)
       step = fold_convert (sizetype, step);
       record_common_cand (data, base, step, use);
       /* Also record common candidate with offset stripped.  */
-      tree alt_base = strip_offset (base);
-      if (alt_base != base)
+      tree alt_base, alt_offset;
+      split_constant_offset (base, &alt_base, &alt_offset);
+      if (!integer_zerop (alt_offset))
 	record_common_cand (data, alt_base, step, use);
     }