ARM target generates unaligned STRD instruction

Bug #1804004 reported by Michael Johnson on 2018-11-19
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
Undecided
Unassigned

Bug Description

Looks like

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82445

has (re)appeared in

GNU Tools ARM Embedded/7 2018-q2-update

I reproduced with -Os -mcpu=cortex-m4

Hi Michael,

I cannot seem to reproduce this issue:

% 7-2018Q2/linux/gcc-arm-none-eabi-7-2018-q2-update/bin/arm-none-eabi-gcc -S -Os -mcpu=cortex-m4 -mno-unaligned-access strd.c -o - | sed -n '/^x:/,/.L3:/p'
x:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        ldr r3, .L2
        ldr r2, .L2+4
        ldr r3, [r3]
        str r2, [r3, #4]
        ldr r2, .L2+8
        str r2, [r3, #8]
        movs r2, #8
        strh r2, [r3, #12] @ movhi
        bx lr
.L3:

Can you please provide more guidance on how to reproduce it?

Best regards,

Thomas

Changed in gcc-arm-embedded:
status: New → Incomplete

Hi Thomas

This is the command line - the code is the same as the original bug report.

"C:\Program Files (x86)\GNU Tools ARM Embedded\7
2018-q2-update\bin\arm-none-eabi-gcc" -c -fmessage-length=0 -I. -DDEBUG
-D__THUMB -MD -MF "C:/Users/mpj/Documents/CrossWorks Projects/strd/strd
THUMB Debug/main.d" -MQ "strd THUMB Debug/main.o" -g -std=gnu99 -Os
-fomit-frame-pointer -ffunction-sections -fdata-sections main.c -o "strd
THUMB Debug/main.o" -mcpu=cortex-m4 -mlittle-endian -mfloat-abi=soft -mthumb

section .text.x
<x>
     4B04        ldr r3, [pc, #16]
     4A05        ldr r2, [pc, #20]
     681B        ldr r3, [r3]
     4905        ldr r1, [pc, #20]
     E9C31201    strd r1, r2, [r3, #4]
     2208        movs r2, #8
     819A        strh r2, [r3, #12]
     4770        bx lr
     BF00        nop
     00000000    .word 0x00000000
     FFFD0000    .word 0xFFFD0000
     00100008    .word 0x00100008

Regards
Michael
> Hi Michael,
>
> I cannot seem to reproduce this issue:
>
> % 7-2018Q2/linux/gcc-arm-none-eabi-7-2018-q2-update/bin/arm-none-eabi-gcc -S -Os -mcpu=cortex-m4 -mno-unaligned-access strd.c -o - | sed -n '/^x:/,/.L3:/p'
> x:
> @ args = 0, pretend = 0, frame = 0
> @ frame_needed = 0, uses_anonymous_args = 0
> @ link register save eliminated.
> ldr r3, .L2
> ldr r2, .L2+4
> ldr r3, [r3]
> str r2, [r3, #4]
> ldr r2, .L2+8
> str r2, [r3, #8]
> movs r2, #8
> strh r2, [r3, #12] @ movhi
> bx lr
> .L3:
>
> Can you please provide more guidance on how to reproduce it?
>
> Best regards,
>
> Thomas
>
> ** Changed in: gcc-arm-embedded
> Status: New => Incomplete
>

Hi Thomas,

Sorry I didn't see/understand the usage of

-mno-unaligned-access

for some reason I didn't think this would affect the optimiser.

Regards
Michael

> Hi Thomas
>
> This is the command line - the code is the same as the original bug
> report.
>
> "C:\Program Files (x86)\GNU Tools ARM Embedded\7
> 2018-q2-update\bin\arm-none-eabi-gcc" -c -fmessage-length=0 -I.
> -DDEBUG -D__THUMB -MD -MF "C:/Users/mpj/Documents/CrossWorks
> Projects/strd/strd THUMB Debug/main.d" -MQ "strd THUMB Debug/main.o"
> -g -std=gnu99 -Os -fomit-frame-pointer -ffunction-sections
> -fdata-sections main.c -o "strd THUMB Debug/main.o" -mcpu=cortex-m4
> -mlittle-endian -mfloat-abi=soft -mthumb
>
> section .text.x
> <x>
>     4B04        ldr r3, [pc, #16]
>     4A05        ldr r2, [pc, #20]
>     681B        ldr r3, [r3]
>     4905        ldr r1, [pc, #20]
>     E9C31201    strd r1, r2, [r3, #4]
>     2208        movs r2, #8
>     819A        strh r2, [r3, #12]
>     4770        bx lr
>     BF00        nop
>     00000000    .word 0x00000000
>     FFFD0000    .word 0xFFFD0000
>     00100008    .word 0x00100008
>
> Regards
> Michael
>> Hi Michael,
>>
>> I cannot seem to reproduce this issue:
>>
>> %
>> 7-2018Q2/linux/gcc-arm-none-eabi-7-2018-q2-update/bin/arm-none-eabi-gcc
>> -S -Os -mcpu=cortex-m4 -mno-unaligned-access strd.c -o - | sed -n
>> '/^x:/,/.L3:/p'
>> x:
>>          @ args = 0, pretend = 0, frame = 0
>>          @ frame_needed = 0, uses_anonymous_args = 0
>>          @ link register save eliminated.
>>          ldr     r3, .L2
>>          ldr     r2, .L2+4
>>          ldr     r3, [r3]
>>          str     r2, [r3, #4]
>>          ldr     r2, .L2+8
>>          str     r2, [r3, #8]
>>          movs    r2, #8
>>          strh    r2, [r3, #12]   @ movhi
>>          bx      lr
>> .L3:
>>
>> Can you please provide more guidance on how to reproduce it?
>>
>> Best regards,
>>
>> Thomas
>>
>> ** Changed in: gcc-arm-embedded
>>         Status: New => Incomplete
>>
>

Hi Thomas,

If it does then I guess that this must always be set for cortex-m devices?

Regards
Michael
> Hi Thomas,
>
> Sorry I didn't see/understand the usage of
>
> -mno-unaligned-access
>
> for some reason I didn't think this would affect the optimiser.
>
> Regards
> Michael
>
>> Hi Thomas
>>
>> This is the command line - the code is the same as the original bug
>> report.
>>
>> "C:\Program Files (x86)\GNU Tools ARM Embedded\7
>> 2018-q2-update\bin\arm-none-eabi-gcc" -c -fmessage-length=0 -I.
>> -DDEBUG -D__THUMB -MD -MF "C:/Users/mpj/Documents/CrossWorks
>> Projects/strd/strd THUMB Debug/main.d" -MQ "strd THUMB Debug/main.o"
>> -g -std=gnu99 -Os -fomit-frame-pointer -ffunction-sections
>> -fdata-sections main.c -o "strd THUMB Debug/main.o" -mcpu=cortex-m4
>> -mlittle-endian -mfloat-abi=soft -mthumb
>>
>> section .text.x
>> <x>
>>     4B04        ldr r3, [pc, #16]
>>     4A05        ldr r2, [pc, #20]
>>     681B        ldr r3, [r3]
>>     4905        ldr r1, [pc, #20]
>>     E9C31201    strd r1, r2, [r3, #4]
>>     2208        movs r2, #8
>>     819A        strh r2, [r3, #12]
>>     4770        bx lr
>>     BF00        nop
>>     00000000    .word 0x00000000
>>     FFFD0000    .word 0xFFFD0000
>>     00100008    .word 0x00100008
>>
>> Regards
>> Michael
>>> Hi Michael,
>>>
>>> I cannot seem to reproduce this issue:
>>>
>>> %
>>> 7-2018Q2/linux/gcc-arm-none-eabi-7-2018-q2-update/bin/arm-none-eabi-gcc
>>> -S -Os -mcpu=cortex-m4 -mno-unaligned-access strd.c -o - | sed -n
>>> '/^x:/,/.L3:/p'
>>> x:
>>>          @ args = 0, pretend = 0, frame = 0
>>>          @ frame_needed = 0, uses_anonymous_args = 0
>>>          @ link register save eliminated.
>>>          ldr     r3, .L2
>>>          ldr     r2, .L2+4
>>>          ldr     r3, [r3]
>>>          str     r2, [r3, #4]
>>>          ldr     r2, .L2+8
>>>          str     r2, [r3, #8]
>>>          movs    r2, #8
>>>          strh    r2, [r3, #12]   @ movhi
>>>          bx      lr
>>> .L3:
>>>
>>> Can you please provide more guidance on how to reproduce it?
>>>
>>> Best regards,
>>>
>>> Thomas
>>>
>>> ** Changed in: gcc-arm-embedded
>>>         Status: New => Incomplete
>>>
>>
>

Hi Michael,

Cortex-M4 does support unaligned access if enabled at startup. GCC thus assumes the most permissive default and expect the user to pass -mno-unaligned-access if unaligned access is not going to be enabled on the target device.

Best regards,

Thomas

Hi Thomas,

Including ldrd/strd?

Regards
Michael
> Hi Michael,
>
> Cortex-M4 does support unaligned access if enabled at startup. GCC thus
> assumes the most permissive default and expect the user to pass -mno-
> unaligned-access if unaligned access is not going to be enabled on the
> target device.
>
> Best regards,
>
> Thomas
>

Launchpad Janitor (janitor) wrote :

[Expired for GNU Arm Embedded Toolchain because there has been no activity for 60 days.]

Changed in gcc-arm-embedded:
status: Incomplete → Expired

Ich bin bis 04.02. nicht im Haus und kann Ihre Nachricht daher leider nicht bearbeiten. In dringenden Fällen wenden Sie sich bitte an <email address hidden> bzw. für technische Fragen an <email address hidden>.

I am out of office until February 4th and won't be able to read your message. In urgent cases, please refer to <email address hidden> or for technical questions to <email address hidden>.

Mit freundlichen Grüßen / Best regards

Steffen Wolfer

--
Dipl.-Inform. Steffen Wolfer
Software Engineer Embedded Systems

WEISS ROBOTICS GmbH & Co. KG
Karl-Heinrich-Käferle-Str. 8
D-71640 Ludwigsburg, Germany

Phone: +49 7141 94702-22
Fax: +49 7141 94702-99
http://www.weiss-robotics.com

Sitz der Gesellschaft: Ludwigsburg
Registergericht Stuttgart, HRA725006

Pers. haftende Gesellschafterin:
Weiss Robotics Verwaltungs-GmbH, Sitz Ludwigsburg
Registergericht Stuttgart, HRB73310
Geschäftsführer: Dr. Karsten Weiß

[Expired for GNU Arm Embedded Toolchain because there has been no
activity for 60 days.]

** Changed in: gcc-arm-embedded
       Status: Incomplete => Expired

--
You received this bug notification because you are subscribed to GNU Arm
Embedded Toolchain.
Matching subscriptions: Älles
https://bugs.launchpad.net/bugs/1804004

Title:
  ARM target generates unaligned STRD instruction

Status in GNU Arm Embedded Toolchain:
  Expired

Bug description:
  Looks like

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82445

  has (re)appeared in

  GNU Tools ARM Embedded/7 2018-q2-update

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc-arm-embedded/+bug/1804004/+subscriptions

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.