[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 19/29] disas: use QEMU_IS_ALIGNED macro
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH 19/29] disas: use QEMU_IS_ALIGNED macro |
Date: |
Mon, 24 Jul 2017 07:16:41 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
On 07/23/2017 09:52 AM, Paolo Bonzini wrote:
>
> But I agree that QEMU_IS_ALIGNED looks weird here. I think it should
> mostly be used when the argument is a pointer, to hide the cast. Uses
> for non-pointer arguments should be decided on a one-by-one basis; "is
> the first argument an address" is definitely a good thing to consider.
> Another might be "is the second argument a variable", because "i % n ==
> 0" is less efficient than "(i & (n - 1)) == 0".
How often is QEMU_IS_ALIGNED used on non-power-of-2? Would it be worth
rewriting it into bit-wise ops, at the expense of declaring that any
code aligning to other values must open-code their own %? Can we have
the compiler help us ensure that the second argument is a power-of-2?
Conversely, if the compiler is given a constant for the second argument,
and is not optimizing modulo power of two into bitwise ops (at least at
CFLAGS=-O2), then that's a compiler bug.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
Re: [Qemu-devel] [PATCH 19/29] disas: use QEMU_IS_ALIGNED macro, Michael Tokarev, 2017/07/18
[Qemu-devel] [PATCH 20/29] disas: use ARRAY_SIZE macro, Philippe Mathieu-Daudé, 2017/07/18
[Qemu-devel] [PATCH 21/29] qga: use ARRAY_SIZE macro, Philippe Mathieu-Daudé, 2017/07/18
[Qemu-devel] [PATCH 22/29] vmsvga: use ARRAY_SIZE macro, Philippe Mathieu-Daudé, 2017/07/18
[Qemu-devel] [PATCH 23/29] async: use ARRAY_SIZE macro, Philippe Mathieu-Daudé, 2017/07/18