This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug inline-asm/85185] Wider-than-expected load for struct member used as operand of inline-asm with memory clobber at -Og


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

--- Comment #4 from Zev Weiss <zev+gccbug at bewilderbeest dot net> ---
I'm afraid I'm not quite GCC-savvy enough to know exactly what PROMOTE_SUBREG
refers to or which targets it covers (a quick grep of the source tree didn't
appear turn up any clues).

As for the RTL (hopefully I've used the right dump flag here)...

riscv64, 7.2.0:
--
$ riscv64-unknown-elf-gcc -fdump-rtl-expand -S -o /dev/null -Og min.c
$ cat min.c.229r.expand 

;; Function outer (outer, funcdef_no=1, decl_uid=1419, cgraph_uid=1,
symbol_order=2)

Partition 0: size 4 align 8
        sub

;; Generating RTL for gimple basic block 2


try_optimize_cfg iteration 1

Merging block 3 into block 2...
Merged blocks 2 and 3.
Merged 2 and 3 without moving.
Merging block 4 into block 2...
Merged blocks 2 and 4.
Merged 2 and 4 without moving.


try_optimize_cfg iteration 2



;;
;; Full RTL generated for this function:
;;
(note 1 0 3 NOTE_INSN_DELETED)
(note 3 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
(note 2 3 5 2 NOTE_INSN_FUNCTION_BEG)
(insn 5 2 6 2 (set (reg:DI 73)
        (high:DI (symbol_ref:DI ("S") [flags 0x84]  <var_decl 0x7fb9d5a7e3f0
S>))) -1
     (nil))
(insn 6 5 7 2 (set (reg/f:DI 74)
        (lo_sum:DI (reg:DI 73)
            (symbol_ref:DI ("S") [flags 0x84]  <var_decl 0x7fb9d5a7e3f0 S>)))
-1
     (nil))
(insn 7 6 8 2 (set (reg:SI 75)
        (mem/c:SI (plus:DI (reg/f:DI 74)
                (const_int 4 [0x4])) [1 S.P+0 S4 A32])) -1
     (nil))
(insn 8 7 9 2 (set (mem/c:SI (plus:DI (reg/f:DI 67 virtual-stack-vars)
                (const_int -8 [0xfffffffffffffff8])) [1 sub+0 S4 A64])
        (reg:SI 75)) -1
     (nil))
(insn 9 8 10 2 (set (reg:DI 72 [ _2 ])
        (sign_extend:DI (mem/c:HI (plus:DI (reg/f:DI 67 virtual-stack-vars)
                    (const_int -8 [0xfffffffffffffff8])) [2 sub.a+0 S2 A64])))
"min.c":12 -1
     (nil))
(insn 10 9 0 2 (parallel [
            (asm_operands/v ("magic %0") ("") 0 [
                    (subreg/s/u:HI (reg:DI 72 [ _2 ]) 0)
                ]
                 [
                    (asm_input:HI ("r") min.c:12)
                ]
                 [] min.c:12)
            (clobber (mem:BLK (scratch) [0  A8]))
        ]) "min.c":12 -1
     (nil))
--

x86-64, 7.3.0 (for what it's worth):
--
$ gcc -fdump-rtl-expand -S -o /dev/null -Og min.c 
$ cat min.c.229r.expand 

;; Function outer (outer, funcdef_no=1, decl_uid=1803, cgraph_uid=1,
symbol_order=2)


;; Generating RTL for gimple basic block 2


try_optimize_cfg iteration 1

Merging block 3 into block 2...
Merged blocks 2 and 3.
Merged 2 and 3 without moving.
Merging block 4 into block 2...
Merged blocks 2 and 4.
Merged 2 and 4 without moving.


try_optimize_cfg iteration 2



;;
;; Full RTL generated for this function:
;;
(note 1 0 3 NOTE_INSN_DELETED)
(note 3 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
(note 2 3 5 2 NOTE_INSN_FUNCTION_BEG)
(insn 5 2 6 2 (set (reg/f:DI 89)
        (symbol_ref:DI ("S") [flags 0x2]  <var_decl 0x7fc81a86fe10 S>)) -1
     (nil))
(insn 6 5 7 2 (set (reg/v:SI 88 [ sub ])
        (mem/c:SI (plus:DI (reg/f:DI 89)
                (const_int 4 [0x4])) [1 S.P+0 S4 A32])) -1
     (nil))
(insn 7 6 8 2 (set (reg:HI 87 [ _2 ])
        (subreg:HI (reg/v:SI 88 [ sub ]) 0)) "min.c":12 -1
     (nil))
(insn 8 7 0 2 (parallel [
            (asm_operands/v ("magic %0") ("") 0 [
                    (reg:HI 87 [ _2 ])
                ]
                 [
                    (asm_input:HI ("r") min.c:12)
                ]
                 [] min.c:12)
            (clobber (mem:BLK (scratch) [0  A8]))
            (clobber (reg:CCFP 18 fpsr))
            (clobber (reg:CC 17 flags))
        ]) "min.c":12 -1
     (nil))
--

I also realized my distro happens to package cross compilers for avr & aarch64,
though I'm not familiar enough with those ISAs offhand to interpret the
generated code (will attach separately in case they're of interest).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]