From patchwork Thu Jul 13 16:39:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1807379 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.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=x9djjbha; dkim-atps=neutral Received: from server2.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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R20hc6Yhfz20bh for ; Fri, 14 Jul 2023 02:40:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 81344385828E for ; Thu, 13 Jul 2023 16:40:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 81344385828E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689266414; bh=KBs2PzOU9DeQKxHDMQ7IZKSqCKOdKT75u0XBD2Bt3o0=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=x9djjbharPAyozhO+q9Wnk75yeez3Bgq7YL/CdOX/0cUgLO0fB50+m6ZY8+DNO7mJ SSAg26NAomHYRsvYhRMJNv63E0yKjmDyCq6l/+we5OylaTiaUaaVVy/DmC9eq4MyTl 3cxjFrD9k+1Bm+dWGqttGhg67xWqPUwtvYPmuGAg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 57DD23858D1E for ; Thu, 13 Jul 2023 16:39:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 57DD23858D1E Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-51e2a6a3768so1163027a12.0 for ; Thu, 13 Jul 2023 09:39:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689266393; x=1691858393; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=KBs2PzOU9DeQKxHDMQ7IZKSqCKOdKT75u0XBD2Bt3o0=; b=P+msPiAf0jToBq3ZibxUcWKvFlzyx+NZSL8vDSOavDFkjEJjEVztfeMoMyzrpPPZbB 2gB+h2CAZc3QKBDjQUspqDg1PZCYaDW4MqePVVTj52w1jnUFb04HwWUoWJHMglUipr14 XuZCLLVnF9/qT2JnPKolHUFJkYRMLnOYgvZ5B6/+3HeiBTySL33AJ8LNAbaSB2hIpRR/ 9gWJ1pOnncYhMHMQeFRB3AyqNGhXvWVyPTj38CAlc1j3cAwuH3HjI/yAFvUX3/061xZE I9NuIYPWnF8nVj39HiYfMDB4DFLrshVnl5ET1tl2ngCPyJj5TlRFNMg54QRrtkfzXzlu 3tyg== X-Gm-Message-State: ABy/qLZHC/JtAdhk/qd5n8/UoZbznwdx6HEKh/yQGsuIV5Dkv4JURmwt iMPqZaklalRUw5FtzKWSVUGX3fPBMz0VAKlcQ+zvwBfaJxloPQ== X-Google-Smtp-Source: APBJJlH9FF8VCdCCh2bfKI5797krlW8pkxZyZEenyUc9x8qTICdaMIWv5KeBpCwfZa5VMLrUR0Kar7Y7DAjAnQCJvgk= X-Received: by 2002:a50:ee18:0:b0:51d:a679:7555 with SMTP id g24-20020a50ee18000000b0051da6797555mr2182298eds.31.1689266392766; Thu, 13 Jul 2023 09:39:52 -0700 (PDT) MIME-Version: 1.0 Date: Thu, 13 Jul 2023 18:39:41 +0200 Message-ID: Subject: [committed] alpha: Fix computation mode in alpha_emit_set_long_cost [PR106966] To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Uros Bizjak via Gcc-patches From: Uros Bizjak Reply-To: Uros Bizjak Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" PR target/106966 gcc/ChangeLog: * config/alpha/alpha.cc (alpha_emit_set_long_const): Always use DImode when constructing long const. gcc/testsuite/ChangeLog: * gcc.target/alpha/pr106966.c: New test. Bootstrapped and regression tested by Matthias on alpha-linux-gnu. Uros. diff --git a/gcc/config/alpha/alpha.cc b/gcc/config/alpha/alpha.cc index 360b50e20d4..beeab06a1aa 100644 --- a/gcc/config/alpha/alpha.cc +++ b/gcc/config/alpha/alpha.cc @@ -2070,6 +2070,8 @@ static rtx alpha_emit_set_long_const (rtx target, HOST_WIDE_INT c1) { HOST_WIDE_INT d1, d2, d3, d4; + machine_mode mode = GET_MODE (target); + rtx orig_target = target; /* Decompose the entire word */ @@ -2082,6 +2084,9 @@ alpha_emit_set_long_const (rtx target, HOST_WIDE_INT c1) d4 = ((c1 & 0xffffffff) ^ 0x80000000) - 0x80000000; gcc_assert (c1 == d4); + if (mode != DImode) + target = gen_lowpart (DImode, target); + /* Construct the high word */ if (d4) { @@ -2101,7 +2106,7 @@ alpha_emit_set_long_const (rtx target, HOST_WIDE_INT c1) if (d1) emit_move_insn (target, gen_rtx_PLUS (DImode, target, GEN_INT (d1))); - return target; + return orig_target; } /* Given an integral CONST_INT or CONST_VECTOR, return the low 64 bits. */ diff --git a/gcc/testsuite/gcc.target/alpha/pr106966.c b/gcc/testsuite/gcc.target/alpha/pr106966.c new file mode 100644 index 00000000000..7145c2096c6 --- /dev/null +++ b/gcc/testsuite/gcc.target/alpha/pr106966.c @@ -0,0 +1,13 @@ +/* PR target/106906 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mbuild-constants" } */ + +void +do_console (unsigned short *vga) +{ + vga[0] = 'H'; + vga[1] = 'e'; + vga[2] = 'l'; + vga[3] = 'l'; + vga[4] = 'o'; +}