[PATCH] D143422: [LV] Update logic for calculating register usage due to invariants

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 24 09:46:33 PST 2023


fhahn accepted this revision.
fhahn added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!



================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:6133
       // even in the scalar case.
-      unsigned Usage =
-          VFs[i].isScalar() ? 1 : GetRegUsage(Inst->getType(), VFs[i]);
+      bool IsScalar = all_of(cast<Instruction>(Inst)->users(), [&](User *U) {
+        auto *I = dyn_cast<Instruction>(U);
----------------
nit: LoopInvariants stores `Instruction*` ,so there should be no need to use `cast`.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:6134
+      bool IsScalar = all_of(cast<Instruction>(Inst)->users(), [&](User *U) {
+        auto *I = dyn_cast<Instruction>(U);
+        return !I || TheLoop != LI->getLoopFor(I->getParent()) ||
----------------
nit: should be able to use `cast`, as all users of instructions should be other instructions. Then there's also no need to check `!I` in the lambda.


================
Comment at: llvm/test/Transforms/LoopVectorize/AArch64/reg-usage.ll:1
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; REQUIRES: asserts
----------------
this is outdated?


================
Comment at: llvm/test/Transforms/LoopVectorize/AArch64/reg-usage.ll:41
+return:                    ;preds = %loopexit, %L.entry
+  ret i32 undef
+}
----------------
nit: change the function to return void?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143422/new/

https://reviews.llvm.org/D143422



More information about the llvm-commits mailing list