aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/builtins.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gnat.dg/loop_optimization17.adb22
-rw-r--r--gcc/testsuite/gnat.dg/loop_optimization17_pkg.adb5
-rw-r--r--gcc/testsuite/gnat.dg/loop_optimization17_pkg.ads29
-rw-r--r--gcc/tree-ssa-loop-ivopts.c46
7 files changed, 81 insertions, 35 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dda0eb3..b601c0e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,7 +1,12 @@
+2014-01-13 Eric Botcazou <ebotcazou@adacore.com>
+
+ * builtins.c (get_object_alignment_2): Minor tweak.
+ * tree-ssa-loop-ivopts.c (may_be_unaligned_p): Rewrite.
+
2014-01-13 Christian Bruel <christian.bruel@st.com>
* config/sh/sh-mem.cc (sh_expand_cmpnstr): Unroll small sizes and
- optimized non constant lengths.
+ optimized non constant lengths.
2014-01-13 Jakub Jelinek <jakub@redhat.com>
diff --git a/gcc/builtins.c b/gcc/builtins.c
index d963c66..c983768 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -434,7 +434,7 @@ get_object_alignment_2 (tree exp, unsigned int *alignp,
alignment that can prevail. */
if (offset)
{
- int trailing_zeros = tree_ctz (offset);
+ unsigned int trailing_zeros = tree_ctz (offset);
if (trailing_zeros < HOST_BITS_PER_INT)
{
unsigned int inner = (1U << trailing_zeros) * BITS_PER_UNIT;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b22f872..8c0d062 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-13 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/loop_optimization17.adb: New test.
+ * gnat.dg/loop_optimization17_pkg.ad[sb]: New helper.
+
2014-01-13 Christian Bruel <christian.bruel@st.com>
* gcc.target/sh/cmpstrn.c: New case.
diff --git a/gcc/testsuite/gnat.dg/loop_optimization17.adb b/gcc/testsuite/gnat.dg/loop_optimization17.adb
new file mode 100644
index 0000000..2178b65
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/loop_optimization17.adb
@@ -0,0 +1,22 @@
+-- { dg-do run }
+-- { dg-options "-O" }
+
+with Loop_Optimization17_Pkg; use Loop_Optimization17_Pkg;
+
+procedure Loop_Optimization17 is
+
+ Data : Arr;
+
+begin
+
+ Data := (others => (I => 0,
+ V1 => (others => 0.0),
+ V2 => (others => 0.0),
+ S => 0.0));
+
+ for I in Index_T'Range loop
+ Object (I).V1 := F (Data (I).V1);
+ Object (I).V2 := F (Data (I).V2);
+ end loop;
+
+end;
diff --git a/gcc/testsuite/gnat.dg/loop_optimization17_pkg.adb b/gcc/testsuite/gnat.dg/loop_optimization17_pkg.adb
new file mode 100644
index 0000000..20815af
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/loop_optimization17_pkg.adb
@@ -0,0 +1,5 @@
+package body Loop_Optimization17_Pkg is
+
+ function F (V : Vector) return Vector is begin return V; end;
+
+end Loop_Optimization17_Pkg;
diff --git a/gcc/testsuite/gnat.dg/loop_optimization17_pkg.ads b/gcc/testsuite/gnat.dg/loop_optimization17_pkg.ads
new file mode 100644
index 0000000..5b650df
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/loop_optimization17_pkg.ads
@@ -0,0 +1,29 @@
+package Loop_Optimization17_Pkg is
+
+ type vector is array (1..3) of Long_Float;
+
+ type Rec is
+ record
+ I : Integer;
+ V1, V2 : Vector;
+ S : Long_Float;
+ end record;
+
+ for Rec use
+ record
+ I at 0 range 0 .. 31;
+ V1 at 4 range 0 .. 191;
+ V2 at 28 range 0 .. 191;
+ S at 52 range 0 .. 63;
+ end record;
+ for Rec'Alignment use 4;
+ for Rec'Size use 480;
+
+ type Index_T is range 1 .. 5;
+ type Arr is array (Index_T) of Rec;
+
+ Object : Arr;
+
+ function F (V : Vector) return Vector;
+
+end Loop_Optimization17_Pkg;
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 2d96fce..14ba20f 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1668,50 +1668,30 @@ constant_multiple_of (tree top, tree bot, double_int *mul)
}
}
-/* Returns true if memory reference REF with step STEP may be unaligned. */
+/* Return true if memory reference REF with step STEP may be unaligned. */
static bool
may_be_unaligned_p (tree ref, tree step)
{
- 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;
-
/* TARGET_MEM_REFs are translated directly to valid MEMs on the target,
thus they are not misaligned. */
if (TREE_CODE (ref) == TARGET_MEM_REF)
return false;
- /* 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 = get_object_alignment (base);
- base_align = MAX (base_align, TYPE_ALIGN (base_type));
-
- if (mode != BLKmode)
- {
- unsigned mode_align = GET_MODE_ALIGNMENT (mode);
-
- if (base_align < mode_align
- || (bitpos % mode_align) != 0
- || (bitpos % BITS_PER_UNIT) != 0)
- return true;
+ unsigned int align = TYPE_ALIGN (TREE_TYPE (ref));
- if (toffset
- && (highest_pow2_factor (toffset) * BITS_PER_UNIT) < mode_align)
- return true;
+ unsigned HOST_WIDE_INT bitpos;
+ unsigned int ref_align;
+ get_object_alignment_1 (ref, &ref_align, &bitpos);
+ if (ref_align < align
+ || (bitpos % align) != 0
+ || (bitpos % BITS_PER_UNIT) != 0)
+ return true;
- if ((highest_pow2_factor (step) * BITS_PER_UNIT) < mode_align)
- return true;
- }
+ unsigned int trailing_zeros = tree_ctz (step);
+ if (trailing_zeros < HOST_BITS_PER_INT
+ && (1U << trailing_zeros) * BITS_PER_UNIT < align)
+ return true;
return false;
}