Private variables compiler optimization?

Does OpenCL compiler attempts to conduct private variables optimization?

Lets say there are two private variables A and B. A is used only in lines 3-9 and B only in lines 10-23, so there is no overlapping. This means that compiler can use only A without declaring B and allocating it extra memory, by simply substituting B with A.

Is there such thing? (if yes - what about loops?)…

Thank you!

Each OpenCL implementor implements their own compiler, including optimizations. So if you are observing missed opportunities for optmizations on a particular implementation, you should contact the vendor.