From patchwork Fri Feb 7 13:10:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Krebbel X-Patchwork-Id: 318035 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 915D82C00A0 for ; Sat, 8 Feb 2014 00:11:12 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=IOk0R2jQy3mJuLAOcrmmxRvqH1LYGcMCKY8FQUtIgd9ywLK/RG4Il VVNqVyTA4QAnNN0izGpZdCBBp4YZapd0nCaA1fdKTjPVLqi3kolxODFJYjOul94e Kv1mZoJjxRBTyA0qaYE3c5E6fJHeI0X44rNVINByPDlOU9wjoc4xMg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=haVmkgiYyY684qtdCRjSJr5C7sc=; b=gGkDEJ2ObOrWM1ReZ0ht PrjUlkeSuwofe/QoAkqdK+RURSyaSbFs6L/LTaXN4CXKG3bkk+e99HM8VtbfEmZb h9nEdXVBHwPFe62PoSBMy3Xm51C3nuMoYLc4Xv849VGjFTiEVAgBvD3WPgWBhFFf m13taFOO4T5lMGTfaObSrqw= Received: (qmail 15216 invoked by alias); 7 Feb 2014 13:11:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 15207 invoked by uid 89); 7 Feb 2014 13:11:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp14.uk.ibm.com Received: from e06smtp14.uk.ibm.com (HELO e06smtp14.uk.ibm.com) (195.75.94.110) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 07 Feb 2014 13:11:03 +0000 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 7 Feb 2014 13:11:00 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 7 Feb 2014 13:10:59 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 173AB17D805A for ; Fri, 7 Feb 2014 13:11:23 +0000 (GMT) Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s17DAkOE53608620 for ; Fri, 7 Feb 2014 13:10:46 GMT Received: from d06av09.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s17DAwPv017573 for ; Fri, 7 Feb 2014 06:10:58 -0700 Received: from bart (dyn-9-152-212-89.boeblingen.de.ibm.com [9.152.212.89]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with SMTP id s17DAv6h017534 for ; Fri, 7 Feb 2014 06:10:57 -0700 Received: by bart (sSMTP sendmail emulation); Fri, 07 Feb 2014 14:10:56 +0100 Date: Fri, 7 Feb 2014 14:10:56 +0100 From: Andreas Krebbel To: gcc-patches@gcc.gnu.org Subject: [PATCH] S/390: Reject misaligned operands in atomic expanders Message-ID: <20140207131056.GA949@bart> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14020713-1948-0000-0000-000007B9CD9F X-IsSubscribed: yes Hi, on S/390 atomic operands need to be naturally aligned. Otherwise the instruction throws an specification exception. With the patch the expanders reject operands not being properly aligned. This only works if the expander code actually allows atomic expanders to fail. This did not seem to be case for the compare and swap code. Fixed with a separate patch. I'll commit the patch after the optab fix is in. This fixes 45 atomic fails in the testsuite on s390x. Bye, -Andreas- 2014-02-07 Andreas Krebbel * config/s390/s390.md ("atomic_load", "atomic_store") ("atomic_compare_and_swap", "atomic_fetch_"): Reject misaligned operands. commit 9431dff0d0dcf8771689c1df49e0bea50ac96d5a Author: Andreas Krebbel Date: Fri Feb 7 12:51:17 2014 +0100 S/390: Prevent 128bit atomic ops from being used on misaligned memory operands. diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index bccc159..3f86304 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -9108,6 +9108,9 @@ (match_operand:SI 2 "const_int_operand")] ;; model "" { + if (MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (GET_MODE (operands[1]))) + FAIL; + if (mode == TImode) emit_insn (gen_atomic_loadti_1 (operands[0], operands[1])); else if (mode == DImode && !TARGET_ZARCH) @@ -9149,6 +9152,9 @@ { enum memmodel model = (enum memmodel) INTVAL (operands[2]); + if (MEM_ALIGN (operands[0]) < GET_MODE_BITSIZE (GET_MODE (operands[0]))) + FAIL; + if (mode == TImode) emit_insn (gen_atomic_storeti_1 (operands[0], operands[1])); else if (mode == DImode && !TARGET_ZARCH) @@ -9203,6 +9209,9 @@ if (!register_operand (output, mode)) output = gen_reg_rtx (mode); + if (MEM_ALIGN (operands[2]) < GET_MODE_BITSIZE (GET_MODE (operands[2]))) + FAIL; + emit_insn (gen_atomic_compare_and_swap_internal (output, operands[2], operands[3], operands[4])); @@ -9319,6 +9328,9 @@ (match_operand:SI 3 "const_int_operand")] ;; model "TARGET_Z196" { + if (MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (GET_MODE (operands[1]))) + FAIL; + emit_insn (gen_atomic_fetch__iaf (operands[0], operands[1], operands[2])); DONE;