[PATCH] D34726: AMDGPU/SI: Do not insert an instruction into worklist twice in movetovalu

Alfred Huang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 9 06:14:44 PDT 2017


alfred.j.huang updated this revision to Diff 105693.
alfred.j.huang retitled this revision from "AMDGPU/SI: Don not insert an instruction into worklist twice in movetovalu " to "AMDGPU/SI: Do not insert an instruction into worklist twice in movetovalu ".
alfred.j.huang added a comment.

1. Changpeng's newest test case did show the "and" instr to be accessed twice through the 2 phi nodes.  I tried an early version of CL 1419065 and it crashed also, so the problem did exist before.   When a node was inserted into the Worklist twice and processed last in first out, the first pop may modify the instr and replaced it with new ones, the second pop may now have a junk node.  Hence it is possible the problem did not reveal itself by luck earlier on, I guess.    It is imperative to avoid pushing an instr into the Worklist twice.

2. To avoid searching if an instr had already been entered into the Worklist, I am changing the Worklist type from SmallPtrVector to SmallPtrSet.   SmallPtrSet's insert will ensure an item not to be entered twice.  There is a catch for this,  SmallPtrVector access is last in first out, SmallPtrSet is first in first out, this may lead to usage of register order to be different than before, so I added a linear search to get the last item entered.   I don't believe this costs much performance degradation, but guarantee generated code to be same as before.


https://reviews.llvm.org/D34726

Files:
  lib/Target/AMDGPU/SIInstrInfo.cpp
  lib/Target/AMDGPU/SIInstrInfo.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34726.105693.patch
Type: text/x-patch
Size: 6392 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170709/1cfb4963/attachment-0001.bin>


More information about the llvm-commits mailing list