Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1639173ybz; Thu, 30 Apr 2020 02:56:11 -0700 (PDT) X-Google-Smtp-Source: APiQypL7NLjjAiGSF8kGW4GktiLAbZ4JXzHPQwWiW0B+oKDlR/MtSbDM65usFXDqsnDBO9nSnfBx X-Received: by 2002:a05:6402:7d6:: with SMTP id u22mr1759183edy.149.1588240570961; Thu, 30 Apr 2020 02:56:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588240570; cv=none; d=google.com; s=arc-20160816; b=pZ0B7ei/6RQXsPOVkXfT8ifGpD0j2CTYXkNpo8l6NbEfzflSLZa+IQenBWyVa/Qsoz z+Vho8REB7ojZv5zF8zu0j5YwQ7Ho9zDEl3O0E4Wo80cn1Etl7Snga5MsxM8M9Rw2bnn K1Wo2D8mqkbWf47fyszzilY8G1rMRJnE1E9RA6NpLfQuJI0J3QMImwJ/sLT4tHDvt2lU jj9zkFr0kgL/TWdsivNd382xK72SHsiyBaXkh8hB+eW5yxHuB1lVk7SImTCfxOCJ8VrC Mg89tJCjNX4gbUpLjZ7gDdZAKyYN787iVzQVenuk+BaEAj5QAQzUMCsglogCLOQLYfk/ RQpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=qmSLHDctwA7Y0K2XoPg3vLwwA0n0l2XFHecD8WXrQDg=; b=OXWt3VNbWFTYd21AuxFK0ZS1bQNPOyJkVb4pTWf1a7od8te+TQZpOeVInsnoYI/Ayu f/LWF9B7JvPvKrWH/60fOkDNyiAnbqug09szNVt6zi2r9KpOiOV+kIY9ALUj0X3cQMhW 8VYjLguZefxKbjvWIbzNFyVEIk1MlnfhLn9TnRH8KhQtyvSxZlAJzdy4TU9xLfRECn5j RDfLSUgtuINYTr0veHyd8W6d+eO57xF0iiesBqu0slRd0DDih+WFsYVKxf0rKjV10l7D 28wSe/712/9dZqKpabzcGBXOoF2rzFh2feI+YiSVieJxutlkSj6CUl7IYPbk8M/uYPVF 4m0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l4si638312edl.169.2020.04.30.02.55.47; Thu, 30 Apr 2020 02:56:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726631AbgD3JwO convert rfc822-to-8bit (ORCPT + 99 others); Thu, 30 Apr 2020 05:52:14 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:52635 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726405AbgD3JwO (ORCPT ); Thu, 30 Apr 2020 05:52:14 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-128-jza2LrHfM5yaVMLeML32iw-1; Thu, 30 Apr 2020 10:52:09 +0100 X-MC-Unique: jza2LrHfM5yaVMLeML32iw-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 30 Apr 2020 10:52:09 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 30 Apr 2020 10:52:09 +0100 From: David Laight To: 'Takashi Iwai' CC: 'Arnd Bergmann' , Jaroslav Kysela , "Takashi Iwai" , "alsa-devel@alsa-project.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] ALSA: opti9xx: shut up gcc-10 range warning Thread-Topic: [PATCH] ALSA: opti9xx: shut up gcc-10 range warning Thread-Index: AQHWHljP0SPhFOMubESmHZ4J5JyFcqiRUaDQ///yewCAACbi8A== Date: Thu, 30 Apr 2020 09:52:09 +0000 Message-ID: <94cc90ff07364743809698fae2ef7138@AcuMS.aculab.com> References: <20200429190216.85919-1-arnd@arndb.de> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai > Sent: 30 April 2020 09:25 > > On Thu, 30 Apr 2020 10:15:02 +0200, > David Laight wrote: > > > > From: Arnd Bergmann .... > > > +static inline void snd_miro_write_mask(struct snd_miro *chip, > > > + unsigned char reg, unsigned char value, unsigned char mask) > > > +{ > > > + unsigned char oldval = snd_miro_read(chip, reg); > > > > > > -#define snd_miro_write_mask(chip, reg, value, mask) \ > > > - snd_miro_write(chip, reg, \ > > > - (snd_miro_read(chip, reg) & ~(mask)) | ((value) & (mask))) > > > + snd_miro_write(chip, reg, (oldval & ~mask) | (value & mask)); > > > +} > > > > Isn't that likely to add additional masking with 0xff at the call sites? > > You will probably get better code if the arguments are 'unsigned int'. > > I don't think such a micro optimization is needed. > All registers, values and masks in the driver are 8bit, so keeping all > unsigned char is rather an improvement of readability. And every time you do any arithmetic they get extended to int. And if you pass them to a function (as char) the compiler has to mask the result of any arithmetic back to 8 bits. On x86 the compiler can use the 'as if' rule and do 8 bit arithmetic. But only if it can determine that the high bits aren't actually used. On almost every other architecture you are likely to get a lot of masking operations. Just because the domain of a variable of 0..255 doesn't mean that 'unsigned char' is an appropriate type for a variable. For x86-64 (and probably others) 'unsigned int' is usually best for anything that cannot be negative. In particular it saves the sign extension instruction that has to be inserted when an 'int' variable is used as an array index. FWIW I think that somewhere else the ~mask had to be replaced with (mask ^ 0xff) do avoid another spurious compiler warning. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)