Skip to content

-mcpu=cortex-m33 does not set -munaligned-access #59560

Closed
@taralx

Description

Cortex-M33 is ARMv8-M Mainline, which supports unaligned access unless explicitly disabled. It appears to be correct in ARM.td, but as you can see below the output depends on the flag being explictly passed.

Test case:

int ttt(short a[2], short b[2]) {
  return (int)a[0] * (int)b[0] + (int)a[1] * (int)b[1];
}

Output with clang --target=arm-none-eabi -mcpu=cortex-m33 -O3 -S -o- testcase.c:

	ldrsh.w	r2, [r0]
	ldrsh.w	r0, [r0, #2]
	ldrsh.w	r3, [r1, #2]
	ldrsh.w	r1, [r1]
	muls	r0, r3, r0
	smlabb	r0, r1, r2, r0
	bx	lr

Output with clang --target=arm-none-eabi -mcpu=cortex-m33 -munaligned-access -O3 -S -o- testcase.c:

	ldr	r0, [r0]
	ldr	r1, [r1]
	movs	r2, #0
	smlad	r0, r1, r0, r2
	bx	lr

Version: Homebrew clang version 15.0.6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    backend:ARMclang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions