The volatile modifier adds extension instructions

Bug #1956170 reported by home
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
New
Undecided
Unassigned

Bug Description

The volatile modifier adds instructions to expand a variable to a 32-bit value (UXTB, UXTH, SXTB, SXTH).
https://godbolt.org/z/x17nj5Gxq

#include "stdint.h"
struct _st
{
     uint8_t a;
    volatile uint8_t b;
}st;
uint32_t test(uint8_t c)
{
    uint8_t out;
    if(st.a > c) out = st.a;
    else out = st.b;
    return out;
};

test:
  ldr r2, .L3
  ldrb r3, [r2] //reading st.a
  cmp r3, r0
  bhi .L2
  ldrb r3, [r2, #1] //reading st.b
  uxtb r3, r3 // <<<<<
.L2:
  mov r0, r3
  bx lr
.L3:
  .word .LANCHOR0
st:

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

Other bug subscribers

Remote bug watches

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