aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-03 22:30:13 +0000
committermrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-03 22:30:13 +0000
commit84a8b1872907b8836dc33b2e26842edf6171295e (patch)
treeb686a23f6885965ff5c45150d8f117cb9641a64a
parent5869b051c5ef4a69921a64a83afc5630e6922243 (diff)
Radar 4433955apple/gcc-5320
* c-common.c (pointer_int_sum): Strip NOPs for C++. * g++.dg/asm-block-38.C: Add. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/apple-local-200502-branch@110566 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog.apple-ppc1
-rw-r--r--gcc/c-common.c104
-rw-r--r--gcc/testsuite/ChangeLog.apple-ppc1
-rw-r--r--gcc/testsuite/g++.dg/asm-block-38.C17
4 files changed, 73 insertions, 50 deletions
diff --git a/gcc/ChangeLog.apple-ppc b/gcc/ChangeLog.apple-ppc
index 264f2c46708..046906b0bd7 100644
--- a/gcc/ChangeLog.apple-ppc
+++ b/gcc/ChangeLog.apple-ppc
@@ -13,6 +13,7 @@
pointer types through to optimizer and print_operand.
(cw_print_op): Likewise.
* config/asm.h (cw_asm_get_register_var): Add.
+ * c-common.c (pointer_int_sum): Strip NOPs for C++.
2006-02-01 Stuart Hastings <stuart@apple.com>
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 5129fa7a762..a284c230ddf 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -2421,56 +2421,60 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop)
TYPE_UNSIGNED (sizetype)), intop);
/* APPLE LOCAL begin CW asm blocks */
- /* We want to canonicalize PLUS_EXPR into ARRAY_REF for data
- pointers as ARRAY_REFs can be converted into RTL code without
- introducing additional temporaries when not optimizing, which is
- useful as otherwise when all registers are in use by the
- assembly code, we can run reload out of registers. */
-
- if (inside_cw_asm_block
- && flag_ms_asms
- && resultcode == PLUS_EXPR
- && TREE_CODE (ptrop) == ADDR_EXPR
- && !(TREE_CODE (TREE_TYPE (TREE_TYPE (ptrop))) == FUNCTION_TYPE
- || TREE_CODE (TREE_TYPE (TREE_TYPE (ptrop))) == METHOD_TYPE))
- {
- tree type;
- tree array = ptrop;
- tree r;
- tree new_i;
-
- size_exp = convert (TREE_TYPE (intop), size_exp);
-
- /* We have to ensure that when ARRAY_REF is used, it will
- calculate the offset correctly as it is element based, and we
- are byte based. */
- new_i = fold (build_binary_op (CEIL_DIV_EXPR, intop, size_exp, 1));
- if (build_binary_op (MULT_EXPR, new_i, size_exp, 1) == intop)
- {
- array = TREE_OPERAND (array, 0);
- type = TREE_TYPE (TREE_TYPE (array));
- if (TREE_CODE (type) != ARRAY_TYPE)
- type = TYPE_MAIN_VARIANT (type);
- r = build4 (ARRAY_REF, type, array, new_i, NULL_TREE, NULL_TREE);
- TREE_READONLY (r)
- |= (TYPE_READONLY (TREE_TYPE (TREE_TYPE (array)))
- | TREE_READONLY (array));
- TREE_SIDE_EFFECTS (r)
- |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
- | TREE_SIDE_EFFECTS (array));
- TREE_THIS_VOLATILE (r)
- |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
- /* This was added by rms on 16 Nov 91.
- It fixes vol struct foo *a; a->elts[1]
- in an inline function.
- Hope it doesn't break something else. */
- | TREE_THIS_VOLATILE (array));
- r = fold (r);
- r = build1 (ADDR_EXPR, result_type, r);
- r = fold (r);
- return r;
- }
- }
+ {
+ tree array = ptrop;
+ STRIP_NOPS (array);
+
+ /* We want to canonicalize PLUS_EXPR into ARRAY_REF for data
+ pointers as ARRAY_REFs can be converted into RTL code without
+ introducing additional temporaries when not optimizing, which
+ is useful as otherwise when all registers are in use by the
+ assembly code, we can run reload out of registers. */
+
+ if (inside_cw_asm_block
+ && flag_ms_asms
+ && resultcode == PLUS_EXPR
+ && TREE_CODE (array) == ADDR_EXPR
+ && !(TREE_CODE (TREE_TYPE (TREE_TYPE (array))) == FUNCTION_TYPE
+ || TREE_CODE (TREE_TYPE (TREE_TYPE (array))) == METHOD_TYPE))
+ {
+ tree type;
+ tree r;
+ tree new_i;
+
+ size_exp = convert (TREE_TYPE (intop), size_exp);
+
+ /* We have to ensure that when ARRAY_REF is used, it will
+ calculate the offset correctly as it is element based, and we
+ are byte based. */
+ new_i = fold (build_binary_op (CEIL_DIV_EXPR, intop, size_exp, 1));
+ if (build_binary_op (MULT_EXPR, new_i, size_exp, 1) == intop)
+ {
+ array = TREE_OPERAND (array, 0);
+ type = TREE_TYPE (TREE_TYPE (array));
+ if (TREE_CODE (type) != ARRAY_TYPE)
+ type = TYPE_MAIN_VARIANT (type);
+ r = build4 (ARRAY_REF, type, array, new_i, NULL_TREE, NULL_TREE);
+ TREE_READONLY (r)
+ |= (TYPE_READONLY (TREE_TYPE (TREE_TYPE (array)))
+ | TREE_READONLY (array));
+ TREE_SIDE_EFFECTS (r)
+ |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
+ | TREE_SIDE_EFFECTS (array));
+ TREE_THIS_VOLATILE (r)
+ |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
+ /* This was added by rms on 16 Nov 91.
+ It fixes vol struct foo *a; a->elts[1]
+ in an inline function.
+ Hope it doesn't break something else. */
+ | TREE_THIS_VOLATILE (array));
+ r = fold (r);
+ r = build1 (ADDR_EXPR, result_type, r);
+ r = fold (r);
+ return r;
+ }
+ }
+ }
/* foo+4 is &(char*)foo + 4 in MS asm land, not foo + 4*(elt size). */
if (inside_cw_asm_block && flag_ms_asms)
diff --git a/gcc/testsuite/ChangeLog.apple-ppc b/gcc/testsuite/ChangeLog.apple-ppc
index 5f2d1197ba0..d7b61da316e 100644
--- a/gcc/testsuite/ChangeLog.apple-ppc
+++ b/gcc/testsuite/ChangeLog.apple-ppc
@@ -10,6 +10,7 @@
* gcc.apple/asm-block-37.c: Add.
* gcc.apple/asm-block-38.c: Add.
* g++.dg/asm-block-37.C: Add.
+ * g++.dg/asm-block-38.C: Add.
2006-02-01 Devang Patel <dpatel@apple.com>
diff --git a/gcc/testsuite/g++.dg/asm-block-38.C b/gcc/testsuite/g++.dg/asm-block-38.C
new file mode 100644
index 00000000000..4d95c03d9ba
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asm-block-38.C
@@ -0,0 +1,17 @@
+/* APPLE LOCAL file CW asm blocks */
+/* { dg-do assemble { target i?86*-*-darwin* } } */
+/* { dg-options { -fasm-blocks -msse3 } } */
+/* Radar 4399388 */
+
+void X2_Interpolate2DNoPinFourCol(const char *sPtr,
+ int sRowBytes)
+{
+ int rowfraclo[2];
+ asm {
+ movd [rowfraclo+4], mm6
+ movzx ebx, byte ptr [esi + eax]
+ movq mm2, [edx+32]
+ mov ecx, ecx
+ mov edi, edi
+ }
+}