Hi I found llvm Sink.cpp pass has a bug. Running opt -basicaa -sink diamond.ll moves the load in entry BB to BBX. This is incorrect as there is a store in BB0. It seems Sink pass is not enabled in the O3 pipeline, Is this the reason why it is disabled ? Also, I see sink can not handle sinking across loop either. *** IR Dump Before Code sinking *** define i32 @diamond(i32 %a, i32 %b, i32 %c, i32* dereferenceable(32) %d) { %1 = mul nsw i32 %c, %b %2 = load i32, i32* %d %3 = icmp sgt i32 %a, 0 br i1 %3, label %B0, label %B1 B0: ; preds = %0 store i32 0, i32* %d br label %X B1: ; preds = %0 br label %X X: ; preds = %B1, %B0 %R = sub i32 %1, %2 ret i32 %R } *** IR Dump Before Module Verifier *** define i32 @diamond(i32 %a, i32 %b, i32 %c, i32* dereferenceable(32) %d) { %1 = icmp sgt i32 %a, 0 br i1 %1, label %B0, label %B1 B0: ; preds = %0 store i32 0, i32* %d br label %X B1: ; preds = %0 br label %X X: ; preds = %B1, %B0 %2 = mul nsw i32 %c, %b %3 = load i32, i32* %d %R = sub i32 %2, %3 ret i32 %R } Thanks -Xin