<div dir="ltr">Hi, All,<div><br></div><div>Suppose I define one memory read only intrinsic function "foo" in Intrinsics.td like this </div><div><br></div><div>def int_foo : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrReadMem]>;</div><div><br></div><div>Suppose I have the following IR, which means the intrinsic function "foo" is called 10 times in a loop. Since the parameters of function "foo" are invariant and the function "foo" is defined as "IntrReadMem". I assume the '-licm' can move the function call 'foo' out of the loop body. However, after I use "opt test.ll -basicaa -licm -S", the function call 'foo' is still inside the loop body. Do I misunderstand something here? Any suggestions are appreciated. Thanks a lot.</div><div><br></div><div><div>; Function Attrs: uwtable</div><div>define i32 @_Z5func1i(i32 %a) #0 {</div><div>  br label %1</div><div><br></div><div>; <label>:1                                       ; preds = %3, %0</div><div>  %ret.0 = phi i32 [ 0, %0 ], [ %4, %3 ]</div><div>  %i.0 = phi i32 [ 0, %0 ], [ %5, %3 ]</div><div>  %2 = icmp slt i32 %i.0, 10</div><div>  br i1 %2, label %3, label %6</div><div><br></div><div>; <label>:3                                       ; preds = %1</div><div>  %4 = call i32 @llvm.foo(i32 %a, i32 3)</div><div>  %5 = add nsw i32 %i.0, 1</div><div>  br label %1</div><div><br></div><div>; <label>:6                                       ; preds = %1</div><div>  ret i32 %ret.0</div><div>}</div><div><br></div><div>; Function Attrs: nounwind readonly</div><div>declare i32 @llvm.foo(i32, i32) #1</div></div><div><br></div><div>Regards,</div><div><br></div><div>Xiangyang</div></div>