This is the mail archive of the gcc-patches@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]

Re: PATCH: Properly check the end of basic block


On Thu, Nov 18, 2010 at 12:36 AM, H.J. Lu <hjl.tools@gmail.com> wrote:

>> @@ -118,9 +118,12 @@ move_or_delete_vzeroupper_2 (basic_block bb, bool
>> upper_128bits_set)
>> ? ? ? ? ? ? bb->index, upper_128bits_set);
>>
>> ? insn = BB_HEAD (bb);
>> + ?last = NEXT_INSN (BB_END (bb));
>> ? while (insn != BB_END (bb))
>> ? ? {
>> ? ? ? insn = NEXT_INSN (insn);
>> + ? ? ?if (insn == last)
>> + ? ? ? break;
>>
>> ? ? ? if (!NONDEBUG_INSN_P (insn))
>> ? ? ? ?continue;
>>
>> The change above is not needed. The new check is never triggered - the
>> loop terminates when "insn == BB_END (bb)" at "while", so I fail to
>> see why additional termination for "NEXT_INSN (insn) == NEXT_INSN
>> (BB_END (bb))" is needed.
>
> Here is the patch for
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46519
>
> We have 2 blocks pointing to each others. This patch first scans
> all blocks without moving vzeroupper so that we can have accurate
> information about upper 128bits at block entry.
>
>> (The BB_HEAD (bb) is either a NOTE or CODE_LABEL so it can be skipped
>> with NEXT_INSN.)
>
> Please try gcc.target/i386/avx-vzeroupper-20.c. ?It will
> trigger this condition.

It doesn't even trigger move_or_delete_vzeroupper.

OK, I have hacked gcc a bit to blindly trigger the function in order
to check the loop iself. For your testcase we process following insn
stream:

 2 bb 2  [10000]
 3 bb 3  [7836]
 4 bb 4  [2164]
    1 NOTE_INSN_DELETED
    4 NOTE_INSN_BASIC_BLOCK
   17 NOTE_INSN_PROLOGUE_END
    3 NOTE_INSN_FUNCTION_BEG
    6 flags:CCZ=cmp(di:DI,0)
    7 pc={(flags:CCZ==0)?L14:pc}
      REG_DEAD: flags:CCZ
      REG_BR_PROB: 0x874
    8 NOTE_INSN_BASIC_BLOCK
   20 NOTE_INSN_EPILOGUE_BEG
   10 call <...>
      REG_DEAD: di:DI
      REG_EH_REGION: 0
i  11: barrier
L14:
   15 NOTE_INSN_BASIC_BLOCK
   19 return
i  18: barrier
   16 NOTE_INSN_DELETED

And the loop processed:

Assembling functions:
 bar
======
    4 NOTE_INSN_BASIC_BLOCK
++++++++
    6 flags:CCZ=cmp(di:DI,0)
++++++++
    7 pc={(flags:CCZ==0)?L14:pc}
      REG_DEAD: flags:CCZ
      REG_BR_PROB: 0x874
======
    8 NOTE_INSN_BASIC_BLOCK
++++++++
   10 call <...>
      REG_DEAD: di:DI
      REG_EH_REGION: 0
======
L14:
++++++++
   23 {return;unspec{0;};}

Where "===" precedes instruction, detected as BB_START and "+++"
precedes instructions that passed !NONDEBUG_INSN_P filter.

Please, can you show me the exact insn that was missed in this
particular testcase. I have used "-O3 -mavx -mtune=generic" and I have
to short-circuit the check for uses_vzeroupper_p at the end of
ix86_reorg.

Uros.


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