i386: Clear stack protector scratch with zero/sign-extend instruction
commit1ae921db2fbe0aed5860f560d52bf8920bd8e0f9
authorUros Bizjak <ubizjak@gmail.com>
Fri, 10 Nov 2023 15:22:44 +0000 (10 16:22 +0100)
committerUros Bizjak <ubizjak@gmail.com>
Fri, 10 Nov 2023 15:23:52 +0000 (10 16:23 +0100)
tree3e6b04acbf7001b7b49ff2aa2ef6bfd2055b2e14
parent99177446a22a489ccd60d374f13d8bb7237d54c2
i386: Clear stack protector scratch with zero/sign-extend instruction

Use unrelated register initializations using zero/sign-extend instructions
to clear stack protector scratch register.

Hanlde only SI -> DImode extensions for 64-bit targets, as this is the
only extension that triggers the peephole in a non-negligible number.

Also use explicit check for word_mode instead of mode iterator in peephole2
patterns to avoid pattern explosion.

gcc/ChangeLog:

* config/i386/i386.md (stack_protect_set_1 peephole2):
Explicitly check operand 2 for word_mode.
(stack_protect_set_1 peephole2 #2): Ditto.
(stack_protect_set_2 peephole2): Ditto.
(stack_protect_set_3 peephole2): Ditto.
(*stack_protect_set_4z_<mode>_di): New insn patter.
(*stack_protect_set_4s_<mode>_di): Ditto.
(stack_protect_set_4 peephole2): New peephole2 pattern to
substitute stack protector scratch register clear with unrelated
register initialization involving zero/sign-extend instruction.
gcc/config/i386/i386.md