aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorZdenek Dvorak <dvorakz@suse.cz>2005-01-12 01:05:55 +0100
committerZdenek Dvorak <rakdver@gcc.gnu.org>2005-01-12 00:05:55 +0000
commit0a915e3d7a94aae8a572f3f7a631269980250050 (patch)
treeb73b45d4e9db23918f55c23b3446e4237574ffd5 /gcc
parent78593d78f1800fcdf5d274e7eef51ed6ca379716 (diff)
downloadgcc-0a915e3d7a94aae8a572f3f7a631269980250050.zip
gcc-0a915e3d7a94aae8a572f3f7a631269980250050.tar.gz
gcc-0a915e3d7a94aae8a572f3f7a631269980250050.tar.bz2
re PR tree-optimization/17949 (Tree loop optimization generates unaligned access (STRICT_ALIGNMENT is set))
PR tree-optimization/17949 * tree-ssa-loop-ivopts.c (may_be_unaligned_p): New function. (find_interesting_uses_address): Use it. From-SVN: r93209
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/tree-ssa-loop-ivopts.c35
2 files changed, 41 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1ce0395..20f5d2f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2005-01-11 Zdenek Dvorak <dvorakz@suse.cz>
+
+ PR tree-optimization/17949
+ * tree-ssa-loop-ivopts.c (may_be_unaligned_p): New function.
+ (find_interesting_uses_address): Use it.
+
2005-01-11 Aldy Hernandez <aldyh@redhat.com>
* regrename.c (kill_value): Handle subreg's that won't simplify.
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 7303412..475f45e 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1400,6 +1400,37 @@ idx_record_use (tree base, tree *idx,
return true;
}
+/* Returns true if memory reference REF may be unaligned. */
+
+static bool
+may_be_unaligned_p (tree ref)
+{
+ tree base;
+ tree base_type;
+ HOST_WIDE_INT bitsize;
+ HOST_WIDE_INT bitpos;
+ tree toffset;
+ enum machine_mode mode;
+ int unsignedp, volatilep;
+ unsigned base_align;
+
+ /* The test below is basically copy of what expr.c:normal_inner_ref
+ does to check whether the object must be loaded by parts when
+ STRICT_ALIGNMENT is true. */
+ base = get_inner_reference (ref, &bitsize, &bitpos, &toffset, &mode,
+ &unsignedp, &volatilep, true);
+ base_type = TREE_TYPE (base);
+ base_align = TYPE_ALIGN (base_type);
+
+ if (mode != BLKmode
+ && (base_align < GET_MODE_ALIGNMENT (mode)
+ || bitpos % GET_MODE_ALIGNMENT (mode) != 0
+ || bitpos % BITS_PER_UNIT != 0))
+ return true;
+
+ return false;
+}
+
/* Finds addresses in *OP_P inside STMT. */
static void
@@ -1415,6 +1446,10 @@ find_interesting_uses_address (struct ivopts_data *data, tree stmt, tree *op_p)
&& DECL_NONADDRESSABLE_P (TREE_OPERAND (base, 1)))
goto fail;
+ if (STRICT_ALIGNMENT
+ && may_be_unaligned_p (base))
+ goto fail;
+
ifs_ivopts_data.ivopts_data = data;
ifs_ivopts_data.stmt = stmt;
ifs_ivopts_data.step_p = &step;