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