remove redundant load by GVN() does not work

Hi,

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 “Passes.run(*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.

Regards

Xiangyang