summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-ivopts.c
diff options
context:
space:
mode:
authorrakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-05 23:57:01 +0000
committerrakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-05 23:57:01 +0000
commitd086c30781f710ce82250c96594aaf081c43ce76 (patch)
treeb63dc3d45ef9da76f56093c1e9995ddb30c5190c /gcc/tree-ssa-loop-ivopts.c
parentae288d12cdebc3432e2c370af67ed0f69ded4b1c (diff)
downloadgcc-d086c30781f710ce82250c96594aaf081c43ce76.tar.gz
PR target/20625
* tree-ssa-loop-ivopts.c (generic_type_for): New function. (add_candidate_1): Use generic_type_for instead of unsigned_type_for. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97674 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-loop-ivopts.c')
-rw-r--r--gcc/tree-ssa-loop-ivopts.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index d1bdb7add8e..508f7814f45 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1841,6 +1841,22 @@ strip_offset (tree expr, bool inside_addr, unsigned HOST_WIDE_INT *offset)
return fold_convert (orig_type, expr);
}
+/* Returns variant of TYPE that can be used as base for different uses.
+ For integer types, we return unsigned variant of the type, which
+ avoids problems with overflows. For pointer types, we return void *. */
+
+static tree
+generic_type_for (tree type)
+{
+ if (POINTER_TYPE_P (type))
+ return ptr_type_node;
+
+ if (TYPE_UNSIGNED (type))
+ return type;
+
+ return unsigned_type_for (type);
+}
+
/* Adds a candidate BASE + STEP * i. Important field is set to IMPORTANT and
position to POS. If USE is not NULL, the candidate is set as related to
it. If both BASE and STEP are NULL, we add a pseudocandidate for the
@@ -1853,14 +1869,14 @@ add_candidate_1 (struct ivopts_data *data,
{
unsigned i;
struct iv_cand *cand = NULL;
- tree type;
+ tree type, orig_type;
if (base)
{
- type = TREE_TYPE (base);
- if (!TYPE_UNSIGNED (type))
+ orig_type = TREE_TYPE (base);
+ type = generic_type_for (orig_type);
+ if (type != orig_type)
{
- type = unsigned_type_for (type);
base = fold_convert (type, base);
if (step)
step = fold_convert (type, step);