<div dir="ltr">Hi,<div><br></div><div>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)"<span style="white-space:pre">. It seems GVN does not remove the redundant instructions. Can anyone give me a hint what's going on here?  Any hint is appreciable.</span></div><div><br></div><div>*********************************************************************</div><div><div>cond_3:                                           ; preds = %cond_1_else</div><div>  %a1 = load i32** @a</div><div>  %v41 = load i32* %v4</div><div>  %6 = getelementptr i32* %a1, i32 %v41</div><div>  %7 = load i32* %6</div><div>  %8 = icmp slt i32 %7, 1</div><div>  br i1 %8, label %cond_4, label %cond_4_else</div><div><br></div><div>cond_4_else:                                      ; preds = %cond_3</div><div>  %a2 = load i32** @a</div><div>  %v42 = load i32* %v4</div><div>  %9 = getelementptr i32* %a2, i32 %v42</div><div>  %10 = load i32* %9</div><div>  %11 = icmp sgt i32 %10, %v6_int_34</div><div>  br i1 %11, label %cond_4, label %cond_4_else1</div><div><br></div><div>cond_4_else1:                                     ; preds = %cond_4_else</div><div>  %a3 = load i32** @a</div><div>  %v43 = load i32* %v4</div><div>  %12 = getelementptr i32* %a3, i32 %v43</div><div>  %13 = load i32* %12</div><div>  %v5_int_42 = srem i32 %v2_int_.0, %13</div><div>  %14 = icmp eq i32 %v5_int_42, 0</div><div>  br i1 %14, label %cond_4_else2, label %cond_4</div></div><div><br></div><div>************************************************************************</div><div>(I change the variable's name a little bit for the first four instructions in each BB because the name of variables in my original IR has a long.)</div><div><br></div><div>Regards</div><div><br></div><div>Xiangyang</div></div>