On x86 the compiler (gcc (Debian 14.2.0-8) 14.2.0) may generate
a better code if it sees division and modulo goes together.
Function old new delta
__regmap_init 3740 3732 -8
Total: Before=31159, After=31151, chg -0.03%
clang (Debian clang version 18.1.8) on x86_64 still shows better code
Function old new delta
__regmap_init 3582 3579 -3
Total: Before=39854, After=39851, chg -0.01%
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/base/regmap/regmap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index d2944271022c..4f8ec8528e34 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -758,13 +758,13 @@ struct regmap *__regmap_init(struct device *dev,
map->alloc_flags = GFP_KERNEL;
map->reg_base = config->reg_base;
+ map->reg_shift = config->pad_bits % 8;
- map->format.reg_bytes = BITS_TO_BYTES(config->reg_bits);
map->format.pad_bytes = config->pad_bits / 8;
map->format.reg_shift = config->reg_shift;
+ map->format.reg_bytes = BITS_TO_BYTES(config->reg_bits);
map->format.val_bytes = BITS_TO_BYTES(config->val_bits);
map->format.buf_size = BITS_TO_BYTES(config->reg_bits + config->val_bits + config->pad_bits);
- map->reg_shift = config->pad_bits % 8;
if (config->reg_stride)
map->reg_stride = config->reg_stride;
else
--
2.43.0.rc1.1336.g36b5255a03ac