LLVMdev Digest, Vol 83, Issue 6

Tarun,
what you are asking for would be a very simple instance of an Iterative-
Data-Flow-Algorithm. Look in any compiler theory book that has a chapter on
IDF and you should be able to figure this out for yourself. If that is what you already
did, and you are worrying about performance, I suggest not doing worrying, IDF are
typically fast at converging, and especially one that is this simple.

-Peter Lawrence.