From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31981 invoked by alias); 4 Feb 2006 00:16:25 -0000 Received: (qmail 31878 invoked by uid 48); 4 Feb 2006 00:16:21 -0000 Date: Sat, 04 Feb 2006 00:16:00 -0000 Message-ID: <20060204001621.31877.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug inline-asm/23200] [4.0/4.1/4.2 regression] rejects "i"(&var + 1) In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "mrs at apple dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-02/txt/msg00296.txt.bz2 List-Id: ------- Comment #17 from mrs at apple dot com 2006-02-04 00:16 ------- I've found a way to fix this at -O0 for my code with something like: /* APPLE LOCAL begin CW asm blocks */ { 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; } } } inside pointer_int_sum just before: /* Replace the integer argument with a suitable product by the object size. Do this multiplication as signed, then convert to the appropriate pointer type (actually unsigned integral). */ intop = convert (result_type, build_binary_op (MULT_EXPR, intop, convert (TREE_TYPE (intop), size_exp), 1)); This makes it though gimple without creating any decls and makes it through rtl expansion without creating any new pseduo registers when using an "m" constraint and putting an INDIRECT_REF on it. You can see this working on the apple-local-200502-branch, Radar 4399388. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23200