From patchwork Wed Apr 20 14:20:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 1127 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:49:23 -0000 Delivered-To: patches@linaro.org Received: by 10.224.67.148 with SMTP id r20cs115839qai; Wed, 20 Apr 2011 07:20:27 -0700 (PDT) Received: by 10.236.168.66 with SMTP id j42mr537725yhl.425.1303309227247; Wed, 20 Apr 2011 07:20:27 -0700 (PDT) Received: from mail.codesourcery.com (mail.codesourcery.com [38.113.113.100]) by mx.google.com with ESMTPS id u3si8941783yba.2.2011.04.20.07.20.25 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Apr 2011 07:20:25 -0700 (PDT) Received-SPF: pass (google.com: domain of ams@codesourcery.com designates 38.113.113.100 as permitted sender) client-ip=38.113.113.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ams@codesourcery.com designates 38.113.113.100 as permitted sender) smtp.mail=ams@codesourcery.com Received: (qmail 15428 invoked from network); 20 Apr 2011 14:20:24 -0000 Received: from unknown (HELO ?192.168.0.104?) (ams@127.0.0.2) by mail.codesourcery.com with ESMTPA; 20 Apr 2011 14:20:24 -0000 Message-ID: <4DAEEBA5.70707@codesourcery.com> Date: Wed, 20 Apr 2011 15:20:21 +0100 From: Andrew Stubbs Organization: CodeSourcery User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: patches@linaro.org Subject: [PATCH][ARM] Clean up movw support This patch doesn't change the compiler behaviour; it merely moves the support for MOVW's 16-bit immediate constant to const_ok_for_op. This patch is broken out of my previous (rejected) Thumb2-constants patch. I'll be posting v2 of that patch soon, and this clean up will be required then. OK? Andrew 2011-04-20 Andrew Stubbs gcc/ * config/arm/arm.c (arm_gen_constant): Move mowv support .... (const_ok_for_op): ... to here. --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -2461,6 +2461,13 @@ const_ok_for_op (HOST_WIDE_INT i, enum rtx_code code) switch (code) { + case SET: + /* See if we can use movw. */ + if (arm_arch_thumb2 && (i & 0xffff0000) == 0) + return 1; + else + return 0; + case PLUS: case COMPARE: case EQ: @@ -2820,9 +2827,7 @@ arm_gen_constant (enum rtx_code code, enum machine_mode mode, rtx cond, } /* If we can do it in one insn get out quickly. */ - if (const_ok_for_arm (val) - || (can_negate_initial && const_ok_for_arm (-val)) - || (can_invert && const_ok_for_arm (~val))) + if (const_ok_for_op (val, code)) { if (generate) emit_constant_insn (cond, @@ -2875,15 +2880,6 @@ arm_gen_constant (enum rtx_code code, enum machine_mode mode, rtx cond, switch (code) { case SET: - /* See if we can use movw. */ - if (arm_arch_thumb2 && (remainder & 0xffff0000) == 0) - { - if (generate) - emit_constant_insn (cond, gen_rtx_SET (VOIDmode, target, - GEN_INT (val))); - return 1; - } - /* See if we can do this by sign_extending a constant that is known to be negative. This is a good, way of doing it, since the shift may well merge into a subsequent insn. */