[flang-commits] [flang] [flang] Added LoopInvariantCodeMotion pass for [HL]FIR. (PR #173438)
via flang-commits
flang-commits at lists.llvm.org
Mon Jan 5 06:15:45 PST 2026
================
@@ -0,0 +1,1326 @@
+// RUN: fir-opt -flang-licm --split-input-file %s | FileCheck %s
+
+// Tests checking that Flang's LICM works correctly:
+// * Descriptor loads may be hoisted unless they can be modified inside
+// the loop (e.g. global descriptors may be modifed by calls).
+// * Reads of scalar non-optional variables may be hoisted unless
+// they are ALLOCATABLE or POINTER (which means they can be unallocated
+// or disassociated in loops that have zero iterations).
+// * TODO: any invariant loads may be hoisted in loops having non-zero
+// iterations.
----------------
jeanPerier wrote:
Can you add a test case with a volatile load?
I think your implementation should prevent moving it because of its write effect, but I think there should be a test showing that LICM is not hoisting volatile operations.
https://github.com/llvm/llvm-project/pull/173438
More information about the flang-commits
mailing list