Skip to content

Commit 9b3cd5c

Browse files
andy-shevbroonie
authored andcommitted
regmap: place foo / 8 and foo % 8 closer to each other
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> Link: https://patch.msgid.link/20241121105838.4073659-4-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent a4a7d86 commit 9b3cd5c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/base/regmap/regmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,13 +758,13 @@ struct regmap *__regmap_init(struct device *dev,
758758
map->alloc_flags = GFP_KERNEL;
759759

760760
map->reg_base = config->reg_base;
761+
map->reg_shift = config->pad_bits % 8;
761762

762-
map->format.reg_bytes = BITS_TO_BYTES(config->reg_bits);
763763
map->format.pad_bytes = config->pad_bits / 8;
764764
map->format.reg_shift = config->reg_shift;
765+
map->format.reg_bytes = BITS_TO_BYTES(config->reg_bits);
765766
map->format.val_bytes = BITS_TO_BYTES(config->val_bits);
766767
map->format.buf_size = BITS_TO_BYTES(config->reg_bits + config->val_bits + config->pad_bits);
767-
map->reg_shift = config->pad_bits % 8;
768768
if (config->reg_stride)
769769
map->reg_stride = config->reg_stride;
770770
else

0 commit comments

Comments
 (0)