https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124605
Bug ID: 124605
Summary: GCC fails to generate uxth for extracting lower 16-bit
on cortex-m0plus
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: kuratius at googlemail dot com
Target Milestone: ---
Created attachment 64001
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64001&action=edit
Sample code that shows the behavior when compiled with -O2 -mcpu=cortex-m0plus
https://godbolt.org/z/dWze9oaqj
See the attachment, compiling with
arm-none-eabi-gcc -O2 -mcpu=cortex-m0plus -S uxth.c -o uxth.s | grep uxth
should show that the second case (and equivalent cases, like input & 0xFFFF)
fail to generate the appropriate instruction, while the third case does it as
expected. I would expect all three to generate uxth, not just the first and
third case.