[llvm-commits] [llvm] r122336 - /llvm/trunk/lib/Transforms/Utils/SimplifyInstructions.cpp

Duncan Sands baldrick at free.fr
Tue Dec 21 12:16:05 PST 2010


Hi Chris,

>> If an instruction simplifies, try again to simplify any uses of it.  This is
>> not very important since the pass is only used for testing, but it does make
>> it more realistic.  Suggested by Frits van Bommel.
>
> Cool thanks.
>
>> +      // Add all interesting instructions to the worklist.
>> +      std::set<Instruction*>  Worklist;
>
> Using an std::set for this will cause the pass to work nondeterminstically (based on pointer addresses).  How about using an std::vector like instcombine?  The cost is that deleting an instruction requires scanning (linear time) the vector to see if an instruction is in the worklist multiple times.  If you want to get really crazy, you can use a smallptrset + vector to prevent that.

Frits pointed this out too.  Rather than using a SetVector I went for a queue
to get FIFO semantics, as a simple way of approximately visiting instructions
before their uses (InstructionSimplify works better if operands are simplified
before the instruction).  I don't know what the memory usage and speed of queue
are like, but it doesn't really matter since this pass is just for testing.

Ciao, Duncan.



More information about the llvm-commits mailing list