This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Question regarding preventing optimizing out of register in expansion
- From: "Peryt, Sebastian" <sebastian dot peryt at intel dot com>
- To: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Cc: "Peryt, Sebastian" <sebastian dot peryt at intel dot com>
- Date: Thu, 21 Jun 2018 09:20:18 +0000
- Subject: Question regarding preventing optimizing out of register in expansion
- Dlp-product: dlpe-windows
- Dlp-reaction: no-action
- Dlp-version: 11.0.200.100
Hi,
I'd appreciate if someone could advise me in builtin expansion I'm currently writing.
High level description for what I want to do:
I have 2 operands in my builtin.
First I set register (reg1) with value from operand1 (op1);
Second I call my instruction (reg1 is called implicitly and updated);
At the end I'm setting operand2 (op2) with value from reg1.
Simplified implementation in i386.c I have:
reg1 = gen_reg_rtx (mode);
emit_insn (gen_rtx_SET (reg1, op1);
emit_clobber (reg1);
emit_insn (gen_myinstruction ());
emit_insn (gen_rtx_SET (op2,reg1));
Everything works fine for -O0, but when I move to higher level optimizations
setting value into reg1 (lines before emit_clobber) are optimized out.
I already tried moving emit_clobber just after assignment but it doesn't help.
Could you please suggest how I can prevent it from happening?
Thanks,
Sebastian