[llvm] [LICM] Fold associative binary ops to promote code hoisting (PR #81608)

Sjoerd Meijer via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 17 06:00:53 PDT 2024


================
@@ -2778,6 +2780,60 @@ static bool hoistMulAddAssociation(Instruction &I, Loop &L,
   return true;
 }
 
+/// Reassociate general associative binary expressions of the form
+///
+/// 1. "(LV op C1) op C2" ==> "LV op (C1 op C2)"
+///
+/// where op is an associative binary op, LV is a loop variant, and C1 and C2
+/// are loop invariants.
----------------
sjoerdmeijer wrote:

Just a small nit that you can fix before committing:

    .., and C1 and C2 are loop invariants.

=>

    .., and C1 and C2 are loop invariants that we want to hoist.

Just to make that a bit more explicit. 

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


More information about the llvm-commits mailing list