Re: [net-next 09/17] can: length: can_fd_len2dlc(): simplify length calculcation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/15/21 3:18 PM, Vincent MAILHOL wrote:
> On Fri. 15 janv. 2021 at 22:51, Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> wrote:
>> On 1/15/21 2:20 PM, Vincent MAILHOL wrote:
>>> /* map the data length to an appropriate data length code */
>>> u8 can_fd_len2dlc(u8 len)
>>> {
>>>     switch(len) {
>>>     case 0 ... 8:
>>>         return len;
>>>     case 9 ... 12:
>>>         return 9;
>>>     case 13 ... 16:
>>>         return 10;
>>>     case 17 ... 20:
>>>         return 11;
>>>     case 21 ... 24:
>>>         return 12;
>>>     case 25 ... 32:
>>>         return 13;
>>>     case 33 ... 48:
>>>         return 14;
>>>     case 49 ... 64:
>>>     default:
>>>         return CANFD_MAX_DLC;
>>>     }
>>> }
>>>
>>> And we will just leave the optimizations in the hand of the compiler.
>>
>> I've already tried this. It results in a longer object file on ARM, even if you
>> remove the array....
> 
> You are right. I just checked the assembly code: it does a
> dichotomy which means that in addition to being bigger, it is
> also slower.
> 
> Please forget my previous message, it wasn't really smart.

I had the same idea, as I've never used these new cases I tried it out and was
underwhelmed. At least compared to this tightly packed array.

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux