From patchwork Fri Oct 8 16:56:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 1538485 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=YRvQU/o4; dkim-atps=neutral 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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQvVs48Z0z9s5P for ; Sat, 9 Oct 2021 03:57:09 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6E4CF3858D39 for ; Fri, 8 Oct 2021 16:57:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E4CF3858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1633712227; bh=KbQLM3CxXUkJkOp3vAwligUxwIvtuMxRYJ3Lf/M1kPw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=YRvQU/o4rgBqQCYkHf91l6erscPAS65TwqkkKfzF+NIEtIUh8bRCeItwQ49yFS/pJ ftRhGEzMKcljmQLO8SDMHkhz62jIrRoKongIH/t2agy7aavxtHzmVcNN4cECsr/ObC Mv32or+jucr/91jVJ91s10OMudJ8ckfh2GuWaHXY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 9E2953858D39 for ; Fri, 8 Oct 2021 16:56:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9E2953858D39 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-362-qsEX1Fq3PNi0NrsO3swjCw-1; Fri, 08 Oct 2021 12:56:22 -0400 X-MC-Unique: qsEX1Fq3PNi0NrsO3swjCw-1 Received: by mail-qt1-f197.google.com with SMTP id f11-20020ac80a4b000000b002a778ec70e4so658016qti.21 for ; Fri, 08 Oct 2021 09:56:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=KbQLM3CxXUkJkOp3vAwligUxwIvtuMxRYJ3Lf/M1kPw=; b=Jg0aY1phL84eyUjfiI2VOPZ/F19kRmgHxtSg4jKvh7npqpxkwvc3Ri4CxkNf41shDH 05zmkDdu9GL9xF77wTLbQVE5cb59VC3Fqgry7/GykWI6UrNliJ2qIxcIoFCx2URymADD dree5BePlCiIdNRjY7ofb8UihY6UrE+UjGMJxSdG8t7es6mbkSDlZCxu9RLT9NuaYTyd nBzZ1z/nmu6gcDLJ8vzTH0hRy6p9l+69bO7KGlkgvYcoIfAlL5gB3c++LSna6eCCdZV0 Bw2FlJ1YJO4XkkNQkBV0q2gMAxI3y+4UTa0IYCeADnVdlR1OlqMqsJOy0YFpH5ZXIQ2G /Y4g== X-Gm-Message-State: AOAM533J0H5HZ41WrsZwawfLEdDKfEpoGawz4lezjBXnrZ2TBH6Cqgdv i9ozgSMlXRNe/wVcglW+Enz5zjwsKJ6pjApuP5mMKRNmCo7UQA6lCjHFKkFsAX+7QAVgITgQGmD Sa3kdd8KPuOhC83NQXHwfBNzLXXKSae/uCnNl+kaZEP66YBhx9NpFnNs8cRhz58xS+v8dFQ== X-Received: by 2002:a05:622a:1312:: with SMTP id v18mr13331874qtk.332.1633712182104; Fri, 08 Oct 2021 09:56:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzzQB3UtvGAoY6DZa19HAWcR1oqfC+RaJyILEWxUPh+12cP09f1jX7kwIdDBj6ZqClkrEIJg== X-Received: by 2002:a05:622a:1312:: with SMTP id v18mr13331849qtk.332.1633712181795; Fri, 08 Oct 2021 09:56:21 -0700 (PDT) Received: from [192.168.1.113] ([69.165.238.126]) by smtp.gmail.com with ESMTPSA id e19sm1405574qtg.92.2021.10.08.09.56.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Oct 2021 09:56:21 -0700 (PDT) To: "gcc-patches@gcc.gnu.org" Subject: [committed] LRA: [PR102627] Use at least natural mode during splitting hard reg live range Message-ID: Date: Fri, 8 Oct 2021 12:56:19 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Vladimir Makarov via Gcc-patches From: Vladimir Makarov Reply-To: Vladimir Makarov Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The following patch fixes    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102627 The patch was successfully bootstrapped and tested on x86-64. commit fab2d977e69539aad9bef81caff17de48e53aedf (HEAD -> master) Author: Vladimir N. Makarov Date: Fri Oct 8 10:16:09 2021 -0400 [PR102627] Use at least natural mode during splitting hard reg live range In the PR test case SImode was used to split live range of cx on x86-64 because it was the biggest mode for this hard reg in the function. But all 64-bits of cx contain structure members. We need always to use at least natural mode of hard reg in splitting to fix this problem. gcc/ChangeLog: PR rtl-optimization/102627 * lra-constraints.c (split_reg): Use at least natural mode of hard reg. gcc/testsuite/ChangeLog: PR rtl-optimization/102627 * gcc.target/i386/pr102627.c: New test. diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index 4d734548c38..8f75125fc2e 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -5799,11 +5799,12 @@ split_reg (bool before_p, int original_regno, rtx_insn *insn, part of a multi-word register. In that case, just use the reg_rtx mode. Do the same also if the biggest mode was larger than a register or we can not compare the modes. Otherwise, limit the size to that of - the biggest access in the function. */ + the biggest access in the function or to the natural mode at least. */ if (mode == VOIDmode || !ordered_p (GET_MODE_PRECISION (mode), GET_MODE_PRECISION (reg_rtx_mode)) - || paradoxical_subreg_p (mode, reg_rtx_mode)) + || paradoxical_subreg_p (mode, reg_rtx_mode) + || maybe_gt (GET_MODE_PRECISION (reg_rtx_mode), GET_MODE_PRECISION (mode))) { original_reg = regno_reg_rtx[hard_regno]; mode = reg_rtx_mode; diff --git a/gcc/testsuite/gcc.target/i386/pr102627.c b/gcc/testsuite/gcc.target/i386/pr102627.c new file mode 100644 index 00000000000..8ab9acaf002 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr102627.c @@ -0,0 +1,41 @@ +/* PR rtl-optimization/102627 */ +/* { dg-do run } */ +/* { dg-options "-O1" } */ + +int a, f, l, m, q, c, d, g; +long b, e; +struct g { + signed h; + signed i; + unsigned j; + unsigned k; +}; +unsigned n; +char o; +int *p = &m; +long r(int s) { return s && b ?: b; } +long __attribute__((noipa)) v() { + l = 0 || r(n & o); + return q; +} +void w(int, unsigned, struct g x) { + c ?: a; + for (; d < 2; d++) + *p = x.k; +} +struct g __attribute__((noipa)) y() { + struct g h = {3, 908, 1, 20}; + for (; g; g++) + ; + return h; +} +int main() { + long t; + struct g u = y(); + t = e << f; + w(0, t, u); + v(0, 4, 4, 4); + if (m != 20) + __builtin_abort (); + return 0; +}