[llvm] [MachineLICM] Allow hoisting loads from invariant address (PR #70796)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 1 02:17:24 PDT 2023


================
@@ -0,0 +1,428 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
+; RUN: llc -mtriple=aarch64-linux-gnu < %s | FileCheck %s
+
+define i64 @one_dimensional(ptr %a, ptr %b, i64 %N, i64 %M, i64 %K) {
+; CHECK-LABEL: one_dimensional:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    mov x8, xzr
+; CHECK-NEXT:    cbz x2, .LBB0_2
+; CHECK-NEXT:  .LBB0_1: // %for.body
+; CHECK-NEXT:    // =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:    ldr x9, [x0], #8
+; CHECK-NEXT:    ldr w10, [x1]
+; CHECK-NEXT:    ldr w9, [x9]
+; CHECK-NEXT:    cmp w9, w10
+; CHECK-NEXT:    cinc x8, x8, ne
+; CHECK-NEXT:    subs x2, x2, #1
+; CHECK-NEXT:    b.ne .LBB0_1
+; CHECK-NEXT:  .LBB0_2: // %for.cond.cleanup
+; CHECK-NEXT:    mov x0, x8
+; CHECK-NEXT:    ret
+entry:
+  %cmp4 = icmp eq i64 %N, 0
----------------
david-arm wrote:

I think you can simplify all the tests by removing the comparison of N, M, etc. with 0. We can just unconditionally jump to the `%for.body` block.

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


More information about the llvm-commits mailing list