Last active
October 7, 2022 17:47
-
-
Save ajeddeloh/d6051efe54a1ddf367b5395b7a456008 to your computer and use it in GitHub Desktop.
GCC Wont generate BFI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test.cc: | |
#include <stdint.h> | |
uint32_t emplace(uint32_t into, uint32_t what) { | |
constexpr uint32_t shift = 5; | |
constexpr uint32_t width = 4; | |
constexpr uint32_t mask = ((1 << width) - 1) << shift; | |
return (into & ~mask) | ((what << shift) & mask); | |
} | |
(abridged) test.s generated by arm-none-eabi-g++ -Wall -Wextra -mcpu=cortex-m4 test.cc -c -S -O3: | |
.LFB0: | |
@ args = 0, pretend = 0, frame = 0 | |
@ frame_needed = 0, uses_anonymous_args = 0 | |
@ link register save eliminated. | |
lsls r1, r1, #5 | |
and r1, r1, #480 | |
bic r0, r0, #480 | |
orrs r0, r0, r1 | |
bx lr | |
(abridged) test.s generated by clang -target arm-none-eabi -Wall -Wextra -mcpu=cortex-m4 test.cc -c -S -O3: | |
_Z7emplacejj: | |
.fnstart | |
bfi r0, r1, #5, #4 | |
bx lr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment