This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/64037] Miscompilation with LTO and enum class : char parameter
- From: "hjl.tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 24 Nov 2014 19:25:20 +0000
- Subject: [Bug rtl-optimization/64037] Miscompilation with LTO and enum class : char parameter
- Auto-submitted: auto-generated
- References: <bug-64037-4 at http dot gcc dot gnu dot org/bugzilla/>
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.