remove redundant load by GVN() does not work


Assume I have the following code. The first four instructions in each BB does the same thing. So I think GVN() can remove the redundant code. However, after I apply GVN to my module by “Passes.add(createGVNPass())” and “*myModule)”. It seems GVN does not remove the redundant instructions. Can anyone give me a hint what’s going on here? Any hint is appreciable.

Add basicaa. Without aa, it won’t touch these

Thanks, Daniel. basicaa works.