[llvm] [LICM] Remove unnecessary check during store hoisting (PR #187529)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 07:43:53 PDT 2026


================
@@ -277,6 +277,35 @@ exit:
   ret i32 %val
 }
 
+define i32 @unrelated_read(ptr noalias %loc, ptr noalias %otherloc) {
+; CHECK-LABEL: define i32 @unrelated_read(
+; CHECK-SAME: ptr noalias [[LOC:%.*]], ptr noalias [[OTHERLOC:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*]]:
+; CHECK-NEXT:    call void @store(i32 0, ptr [[LOC]])
----------------
antoniofrighetto wrote:

Oh, scratch the above. What I had in mind when posting that snippet (plus writeonly to `@store`) was that, with this change, IndVarSimplify would simplify the loop leading to the second call to `@store` being never called. This is just a missed optimization, unrelated to the patch (likewise, I stand corrected, writeonly would be enough here to prove that the second call is redundant, as the call to `@load` in between really just reads argument memory).

https://github.com/llvm/llvm-project/pull/187529


More information about the llvm-commits mailing list