🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #42623

Why 2 memory access for a single store?

#42623
From: malhar m. palkar
Date: Thu, 16 Nov 1995 00:00
51 lines
1533 bytes
Hi,

Please help me with following code. I have following 'C'
code.

int *bar;
int  *bar  = (int *)  0x00fc0000;

main()
{
   bar[1] = 100;
}
++++++++++++++++++++++++++++++++++++++++
And it generates following assembly code.
gcc2_compiled.:
___gnu_compiled_c:
        .global _bar
.data
        .align 4
_bar:
        .word   16515072
.text
        .align 4
        .global _main
        .proc   04
_main:
        !#PROLOGUE# 0
        save %sp,-104,%sp
        !#PROLOGUE# 1
        call ___main,0
        nop
        mov 4,%o0
        sethi %hi(_bar),%o2
        ld [%o2+%lo(_bar)],%o1             !Why load
        add %o0,%o1,%o0
        mov 100,%o1
        st %o1,[%o0]
L1:
        ret
        restore
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
My question is why do you need the intermidiate load
to load a constant value in %o1? Is it possible to define
it differently so as to avoid that.

This is a serious issue with me as ld and store from data
sections are expensive in our architecture.

Thanks for all the help.

/MALHAR
Technical Details
Message-ID: <48g5sj$e6q@elaine23.Stanford.EDU>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,8407a954af66f05c,start
X-Google-Attributes: gid11318c,public
From: palkar@leland.Stanford.EDU (malhar m. palkar)
Subject: Why 2 memory access for a single store?
Date: 1995/11/16
Message-ID: <48g5sj$e6q@elaine23.Stanford.EDU>
X-Deja-AN: 119515613
sender: palkar@leland.stanford.edu
organization: Stanford University, CA 94305, USA
newsgroups: gnu.gcc.help