From patchwork Thu Sep 1 11:24:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 3836 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 79B3E23F36 for ; Thu, 1 Sep 2011 11:24:35 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 6675DA1862C for ; Thu, 1 Sep 2011 11:24:35 +0000 (UTC) Received: by fxd18 with SMTP id 18so846467fxd.11 for ; Thu, 01 Sep 2011 04:24:35 -0700 (PDT) Received: by 10.223.62.8 with SMTP id v8mr175030fah.43.1314876262147; Thu, 01 Sep 2011 04:24:22 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs48917lab; Thu, 1 Sep 2011 04:24:21 -0700 (PDT) Received: by 10.236.37.202 with SMTP id y50mr509253yha.101.1314876260386; Thu, 01 Sep 2011 04:24:20 -0700 (PDT) Received: from mail.codesourcery.com (mail.codesourcery.com [38.113.113.100]) by mx.google.com with ESMTPS id j69si1444141yhe.61.2011.09.01.04.24.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Sep 2011 04:24:20 -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 3458 invoked from network); 1 Sep 2011 11:24:17 -0000 Received: from unknown (HELO ?192.168.0.104?) (ams@127.0.0.2) by mail.codesourcery.com with ESMTPA; 1 Sep 2011 11:24:17 -0000 Message-ID: <4E5F6B5F.2020207@codesourcery.com> Date: Thu, 01 Sep 2011 12:24:15 +0100 From: Andrew Stubbs Organization: CodeSourcery User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110812 Thunderbird/6.0 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: patches@linaro.org Subject: [PATCH][ARM] pr50193: ICE on a | (b << negative-constant) This patch should fix the bug in pr50193. The problem is that the arith_shiftsi pattern accepted any arbitrary constant as the shift amount (via the shift_amount_operand predicate) where in fact the constant must be in the range 0..32. This patch fixes the problem by merely checking that the constant is positive. I've confirmed that values larger than the mode-size are not a problem because the compiler optimizes those away earlier, even at -O0. OK? Andrew 2011-09-01 Andrew Stubbs gcc/ * config/arm/predicates.md (shift_amount_operand): Ensure shift amount is positive. gcc/testsuite/ * gcc.dg/pr50193-1.c: New file. --- a/gcc/config/arm/predicates.md +++ b/gcc/config/arm/predicates.md @@ -132,7 +132,8 @@ (define_predicate "shift_amount_operand" (ior (and (match_test "TARGET_ARM") (match_operand 0 "s_register_operand")) - (match_operand 0 "const_int_operand"))) + (and (match_operand 0 "const_int_operand") + (match_test "INTVAL (op) > 0")))) (define_predicate "arm_add_operand" (ior (match_operand 0 "arm_rhs_operand") --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr50193-1.c @@ -0,0 +1,10 @@ +/* PR 50193: ARM: ICE on a | (b << negative-constant) */ +/* Ensure that the compiler doesn't ICE. */ + +/* { dg-options "-O2" } */ + +int +foo(int a, int b) +{ + return a | (b << -3); /* { dg-warning "left shift count is negative" } */ +}