From patchwork Mon Apr 13 23:39:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 1269985 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=jj9Gkltn; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 491Q7r3Xbdz9s71 for ; Tue, 14 Apr 2020 09:39:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 41918385DC10; Mon, 13 Apr 2020 23:39:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 41918385DC10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586821171; bh=cBYOrC6bJ1P/MyHr+LH26qQwClztccAfZakICv3ZuEI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=jj9Gkltn+sqoBEjT4dDccM0s66UCHpZ9DISikQUTPJLflCUJ/7NeN2PqyF17RWMZo awZAUTT026ld7rRIM+2G5VgJ6H7deLzLppfNvNQhb+LdjM4qRda/IQAp0SW/INdGNf alzFZ7ZJpeOYuGEF7VndHYX+ZY0IXVo6CEYLJM2c= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by sourceware.org (Postfix) with ESMTPS id 2DFA1385DC04 for ; Mon, 13 Apr 2020 23:39:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2DFA1385DC04 Received: by mail-pj1-x1042.google.com with SMTP id a32so4507508pje.5 for ; Mon, 13 Apr 2020 16:39:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cBYOrC6bJ1P/MyHr+LH26qQwClztccAfZakICv3ZuEI=; b=QRY7gsmCsFXksEbz5+A/XJP/3f1N2yYrXJcoLIxHeAdMyOkUU0YsiRlOW7Pub0/tx6 8icPKMSq6yUMQ+mD2SwxoF0nHvOJo7RCsJGoImaagl2mPk/fHxaXGLLV+hnbNuWFbQb0 K3yiNnHWJ8JeL2sQqjVKGcwWb054tdUVN14T0OIVTTjaZk27ZCs2C6uc1SfoTtJj0H5L LJU2B/fWUxmtjEVLFpXWEGNblFTPVEVoRGCqfSo0dP/m0yciGBQw70RM2d4jTL7TRSBG TeaxabRKUBxKaiK0M5CeGBIpdjdVUp4mInjwxsLD6b2sQmQ75sWVPr+/57b567HW5Sg7 ZB+Q== X-Gm-Message-State: AGi0PubOSAjD631hEADjMeGWRCWSz5fCtAQ5tBfSy8R7NkGPpMR/A/0v Go3NUje0JSpQ8xxtWmhMjq1npZk/ X-Google-Smtp-Source: APiQypKeQEn1ptTPvjGqow8FwMKIs3xOyyXqDqduOlvz03LceCb/dY3yvRiNUM6AoAZv3XU/WSkmzg== X-Received: by 2002:a17:90a:2149:: with SMTP id a67mr15627819pje.43.1586821166864; Mon, 13 Apr 2020 16:39:26 -0700 (PDT) Received: from octofox.cadence.com ([2601:641:400:63f0:a487:3b8:7ffc:c9e4]) by smtp.gmail.com with ESMTPSA id q7sm9713656pfc.166.2020.04.13.16.39.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 16:39:26 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] xtensa: fix PR target/94584 Date: Mon, 13 Apr 2020 16:39:01 -0700 Message-Id: <20200413233901.2417-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-23.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HK_RANDOM_ENVFROM, HK_RANDOM_FROM, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Max Filippov via Gcc-patches From: Max Filippov Reply-To: Max Filippov Cc: Sterling Augustine , linux-xtensa@linux-xtensa.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Patterns zero_extendhisi2, zero_extendqisi2 and extendhisi2_internal can load value from memory, but they don't treat volatile memory correctly. Add %v1 before load instructions to emit 'memw' instruction when -mserialize-volatile is in effect. 2020-04-13 Max Filippov gcc/ * config/xtensa/xtensa.md (zero_extendhisi2, zero_extendqisi2) (extendhisi2_internal): Add %v1 before the load instructions. gcc/testsuite/ * gcc.target/xtensa/pr94584.c: New test. --- gcc/config/xtensa/xtensa.md | 6 +++--- gcc/testsuite/gcc.target/xtensa/pr94584.c | 24 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/xtensa/pr94584.c diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 5b803d3cbe65..749fe477d562 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -538,7 +538,7 @@ "" "@ extui\t%0, %1, 0, 16 - l16ui\t%0, %1" + %v1l16ui\t%0, %1" [(set_attr "type" "arith,load") (set_attr "mode" "SI") (set_attr "length" "3,3")]) @@ -549,7 +549,7 @@ "" "@ extui\t%0, %1, 0, 8 - l8ui\t%0, %1" + %v1l8ui\t%0, %1" [(set_attr "type" "arith,load") (set_attr "mode" "SI") (set_attr "length" "3,3")]) @@ -575,7 +575,7 @@ "" "@ sext\t%0, %1, 15 - l16si\t%0, %1" + %v1l16si\t%0, %1" [(set_attr "type" "arith,load") (set_attr "mode" "SI") (set_attr "length" "3,3")]) diff --git a/gcc/testsuite/gcc.target/xtensa/pr94584.c b/gcc/testsuite/gcc.target/xtensa/pr94584.c new file mode 100644 index 000000000000..1577285b8a68 --- /dev/null +++ b/gcc/testsuite/gcc.target/xtensa/pr94584.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mserialize-volatile" } */ + +unsigned long load32 (volatile unsigned long *s) +{ + return *s; +} + +short load16s (volatile short *s) +{ + return *s; +} + +unsigned short load16u (volatile unsigned short *s) +{ + return *s; +} + +unsigned char load8 (volatile unsigned char *s) +{ + return *s; +} + +/* { dg-final { scan-assembler-times "memw" 4 } } */