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 rtl-optimization/64037] Miscompilation with LTO and enum class : char parameter


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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|target                      |rtl-optimization
   Target Milestone|---                         |4.9.3

--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
On x86, we don't require promoting QI/HI argument to SI.
Depending on optimization choice, we may generate SI move
for QI argument:

    movl    $2, %ecx    # 9    *movqi_internal/2    [length = 5]

For -Os, we generate:

    movb    $2, %cl    # 9    *movqi_internal/2    [length = 2]

since movb is shorter.  It is a pure luck that it only fails with -Os.
The combine pass turns

(insn 2 7 4 2 (set (reg/v/f:SI 88 [ out ])
        (reg:SI 0 ax [ out ])) ../pr64037.ii:8 90 {*movsi_internal}
     (expr_list:REG_DEAD (reg:SI 0 ax [ out ])
        (nil)))
(insn 4 2 6 2 (set (reg:SI 91 [ b ])
        (reg:SI 2 cx [ b ])) ../pr64037.ii:8 90 {*movsi_internal}
     (expr_list:REG_DEAD (reg:SI 2 cx [ b ])
        (nil)))
(note 6 4 9 2 NOTE_INSN_FUNCTION_BEG)
(insn 9 6 10 2 (set (reg:SI 92 [ b ])
        (zero_extend:SI (subreg:QI (reg:SI 91 [ b ]) 0))) ../pr64037.ii:9 138
{*
zero_extendqisi2}
     (expr_list:REG_DEAD (reg:SI 91 [ b ])
        (nil)))
(insn 10 9 0 2 (set (mem:SI (reg/v/f:SI 88 [ out ]) [1 *out_4(D)+0 S4 A32])
        (reg:SI 92 [ b ])) ../pr64037.ii:9 90 {*movsi_internal}
     (expr_list:REG_DEAD (reg:SI 92 [ b ])
        (expr_list:REG_DEAD (reg/v/f:SI 88 [ out ])
            (nil))))

into

(insn 2 7 4 2 (set (reg/v/f:SI 88 [ out ])
        (reg:SI 0 ax [ out ])) pr64037.ii:8 90 {*movsi_internal}
     (expr_list:REG_DEAD (reg:SI 0 ax [ out ])
        (nil)))
(insn 4 2 6 2 (set (reg:SI 91 [ b ])
        (reg:SI 2 cx [ b ])) pr64037.ii:8 90 {*movsi_internal}
     (expr_list:REG_DEAD (reg:SI 2 cx [ b ])
        (nil)))
(note 6 4 9 2 NOTE_INSN_FUNCTION_BEG)
(note 9 6 10 2 NOTE_INSN_DELETED)
(insn 10 9 0 2 (set (mem:SI (reg/v/f:SI 88 [ out ]) [1 *out_4(D)+0 S4 A32])
        (reg:SI 91 [ b ])) pr64037.ii:9 90 {*movsi_internal}
     (expr_list:REG_DEAD (reg:SI 91 [ b ])
        (expr_list:REG_DEAD (reg/v/f:SI 88 [ out ])
            (nil))))

It is certainly wrong.


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