From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id 754FF388A41D for ; Wed, 2 Jun 2021 18:27:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 754FF388A41D Received: by mail-pj1-x1031.google.com with SMTP id d5-20020a17090ab305b02901675357c371so3617816pjr.1 for ; Wed, 02 Jun 2021 11:27:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=pORryT2HSWI3DOQbxVHGB26Wr0zCNLUywV69rdbGXj8=; b=K7CjQMdrQYPuG/lAf9GNZEqAWOjAZd/sgRjZv15FpDQMerLzb6v8MRuzEUxXA0mUiG AqF7NLfILnagt/kEqKmbXhtygLVchYUN/eNcXCgKcdOsjMCc5dgZjBXYWJl/Vm6t8deQ qVxSpUt5cxb95KduDd5ak4uTU8hH94CXCgR1O3yjGVlZSbCkKkX6D8FErJvnIWpljBnN X3XfWd8rN2XgZhFFihfWe5w04Nkz7uWGPRbGRFmgeJ717osiw14VqA1OAWLdXiZ33MJq TKJM1aBZTQtFy3Hka5rfd3nQFu7H6N39+hoTJWQmPkRamWUGZNKpVow2EehQ1X6ymCPe 0spQ== X-Gm-Message-State: AOAM530S/PVB62GqeqWcaiICWi/Z61d+ZMnmda+74VHmSmMcDnPnJh73 x6iO/60zlSBcOswrmDgBnp83Ic4cTL5QRQ== X-Google-Smtp-Source: ABdhPJwLy0wulKmXtlUGqTbt5bPUIuK7QHTpoGfF2jrDB7VBculPjbNhQ2IkE32KcFDdXnXw+4owoQ== X-Received: by 2002:a17:90a:a41:: with SMTP id o59mr6673188pjo.203.1622658458361; Wed, 02 Jun 2021 11:27:38 -0700 (PDT) Received: from [172.31.0.175] (c-98-202-48-222.hsd1.ut.comcast.net. [98.202.48.222]) by smtp.gmail.com with ESMTPSA id d66sm281498pfa.32.2021.06.02.11.27.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Jun 2021 11:27:38 -0700 (PDT) Subject: Re: [PATCH] xtensa: Fix 2 warnings during xtensa build [PR100841] To: Jakub Jelinek , Sterling Augustine , Max Filippov , Eric Botcazou Cc: gcc-patches@gcc.gnu.org References: <20210602170926.GA7746@tucnak> From: Jeff Law Message-ID: Date: Wed, 2 Jun 2021 12:27:36 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <20210602170926.GA7746@tucnak> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A, 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-List-Received-Date: Wed, 02 Jun 2021 18:27:40 -0000 On 6/2/2021 11:09 AM, Jakub Jelinek wrote: > Hi! > > When building gcc targetting xtensa-linux, there are 2 warnings the PR > complains about: > ../../gcc/dwarf2cfi.c: In function ‘void init_one_dwarf_reg_size(int, machine_mode, rtx, machine_mode, init_one_dwarf_reg_state*)’: > ../../gcc/dwarf2cfi.c:291:12: warning: comparison of integer expressions of different signedness: ‘const unsigned int’ and ‘int’ [-Wsign-compare] > 291 | if (rnum >= DWARF_FRAME_REGISTERS) > ../../gcc/function.c: In function ‘void gen_call_used_regs_seq(rtx_insn*, unsigned int)’: > ../../gcc/function.c:5897:63: warning: comparison of unsigned expression in ‘< 0’ is always false [-Wtype-limits] > 5897 | if (crtl->uses_only_leaf_regs && LEAF_REG_REMAP (regno) < 0) > which might during bootstrap or when configured with --enable-werror-always > be turned into errors. > > The first one is the -Wsign-compare warning, in c-family we do: > 2281 /* Do not warn if the signed quantity is an unsuffixed integer > 2282 literal (or some static constant expression involving such > 2283 literals or a conditional expression involving such literals) > 2284 and it is non-negative. */ > 2285 if (tree_expr_nonnegative_warnv_p (sop, &ovf)) > 2286 /* OK */; > and so don't warn if that function determines the expression is > non-negative. But xtensa defines DWARF_FRAME_REGISTERS as > (16 + (something ? 0 : 1)) and that isn't handled by > tree_expr_nonnegative_warnv_p, VRP can handle it of course, but that is much > later. > The second chunk rewrites it into a form that tree_expr_nonnegative_warnv_p > can handle, in particular (something ? 16 : 16 + 1), where for COND_EXPRs > that function checks both the 2nd and 3rd operand of the ternary operator > and if both are nonnegative, returns true. > > The other warning has been introduced fairly recently; LEAF_REG_REMAP is > currently used by 2 targets only, and is documented to yield -1 if a hard > reg number can't be remapped and the remapped register number otherwise. > That means that the type of the expression should be signed (otherwise -1 > could never appear), and on SPARC indeed it is defined as > extern char leaf_reg_remap[]; > #define LEAF_REG_REMAP(REGNO) (leaf_reg_remap[REGNO]) > so unless the host is -funsigned-char by default it works fine. > I guess sparc.[ch] should be fixed to use signed char of leaf_reg_remap, > Eric? > The argument to LEAF_REG_REMAP is often unsigned int though, hard > register numbers are usually not negative, and thus the warning. > I think xtensa doesn't have 2G hard registers and so it is ok to just cast > it to int. > > Verified just by making sure the warnings go away in a cross, ok for trunk? > > 2021-06-02 Jakub Jelinek > > PR target/100841 > * config/xtensa/xtensa.h (LEAF_REG_REMAP): Cast REGNO to int to avoid > -Wtype-limits warnings. > (DWARF_FRAME_REGISTER): Rewrite into ternary operator with addition > in operands to avoid -Wsign-compare warnings. OK. jeff