[PATCH] D113290: [WIP] [AArch64TargetMachine] Enable LICM Hosting LOAD only optimization in case of -O3

Djordje Todorovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 5 08:29:34 PDT 2021


djtodoro created this revision.
djtodoro added a project: LLVM.
Herald added subscribers: asbirlea, hiraditya, kristof.beyls.
djtodoro requested review of this revision.
Herald added a subscriber: llvm-commits.

Enable LICM Hosting LOAD only optimization in case of -O3.

NOTE: This doesn't depend on the SeparateConstOffsetFromGEP, but the flag for this optimization will be enabled iff the SeparateConstOffsetFromGEP is active in the case of AARCH64 target, which is the goal arch for this stack of patches.

This addresses [0].
[0] https://bugs.llvm.org/show_bug.cgi?id=51193

Co-authored-by: @mmatic05, @milica-lazarevic, @dmilosevic141


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113290

Files:
  llvm/include/llvm/Transforms/Scalar.h
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/lib/Transforms/Scalar/LICM.cpp
  llvm/test/Transforms/LICM/AArch64/hoist-load-without-store.ll


Index: llvm/test/Transforms/LICM/AArch64/hoist-load-without-store.ll
===================================================================
--- llvm/test/Transforms/LICM/AArch64/hoist-load-without-store.ll
+++ llvm/test/Transforms/LICM/AArch64/hoist-load-without-store.ll
@@ -14,10 +14,12 @@
 ;; }
 
 ; RUN: opt -licm -licm-load-hoisting-only -mtriple aarch64-linux-gnu -S < %s | FileCheck %s
+; RUN: llc -O3 -print-after=codegenprepare < %s 2>&1 | FileCheck %s
 
 ; CHECK-LABEL: for.body.preheader:
-; CHECK: %u.promoted = load i32, i32* @u
-; CHECK: %v.promoted = load i32, i32* @v
+; CHECK: load i32, i32* @u
+; CHECK-NEXT: load i32, i32* @v
+; CHECK-NEXT: br label %for.body
 
 ; ModuleID = './test.ll'
 source_filename = "test.c"
Index: llvm/lib/Transforms/Scalar/LICM.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LICM.cpp
+++ llvm/lib/Transforms/Scalar/LICM.cpp
@@ -332,7 +332,10 @@
 INITIALIZE_PASS_END(LegacyLICMPass, "licm", "Loop Invariant Code Motion", false,
                     false)
 
-Pass *llvm::createLICMPass() { return new LegacyLICMPass(); }
+Pass *llvm::createLICMPass(bool TryHoistingLoadOnly) {
+  EnableLoadHoistOnly = TryHoistingLoadOnly;
+  return new LegacyLICMPass();
+}
 Pass *llvm::createLICMPass(unsigned LicmMssaOptCap,
                            unsigned LicmMssaNoAccForPromotionCap) {
   return new LegacyLICMPass(LicmMssaOptCap, LicmMssaNoAccForPromotionCap);
Index: llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+++ llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -562,7 +562,7 @@
     addPass(createEarlyCSEPass());
     // Do loop invariant code motion in case part of the lowered result is
     // invariant.
-    addPass(createLICMPass());
+    addPass(createLICMPass(/*TryHoistingLoadOnly*/ true));
   }
 
   // Add Control Flow Guard checks.
Index: llvm/include/llvm/Transforms/Scalar.h
===================================================================
--- llvm/include/llvm/Transforms/Scalar.h
+++ llvm/include/llvm/Transforms/Scalar.h
@@ -131,7 +131,7 @@
 //
 // LICM - This pass is a loop invariant code motion and memory promotion pass.
 //
-Pass *createLICMPass();
+Pass *createLICMPass(bool TryHoistingLoadOnly = false);
 Pass *createLICMPass(unsigned LicmMssaOptCap,
                      unsigned LicmMssaNoAccForPromotionCap);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113290.385085.patch
Type: text/x-patch
Size: 2469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211105/ea397c62/attachment.bin>


More information about the llvm-commits mailing list