[PATCH] D144381: [SCEV] Added a utility method that raising the number 2 to the desired power to SCEV

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 27 03:34:34 PST 2023


mkazantsev added a comment.

Code is fine with nits now, but I want to see the application before I approve this.



================
Comment at: llvm/include/llvm/Analysis/ScalarEvolution.h:660
+  const SCEV *getPowerOfTwo(Type *Ty, unsigned Power) {
+    auto Val = APInt::getZero(getTypeSizeInBits(Ty));
+    Val.setBit(Power);
----------------
Assert that `Power` is less than type width?


================
Comment at: llvm/unittests/Analysis/ScalarEvolutionTest.cpp:1750
+  SMDiagnostic Err;
+  std::unique_ptr<Module> M = parseAssemblyString("define void @foo(i64 %x) { "
+                                                  "  ret void "
----------------
param not needed


================
Comment at: llvm/unittests/Analysis/ScalarEvolutionTest.cpp:1760
+    auto *X = SE.getSCEV(getArgByName(F, "x"));
+    Type *Ty = X->getType();
+    for (unsigned short i = 0; i < 64; ++i) {
----------------
Use `Type::getInt64Ty(Ctx)`


================
Comment at: llvm/unittests/Analysis/ScalarEvolutionTest.cpp:1761
+    Type *Ty = X->getType();
+    for (unsigned short i = 0; i < 64; ++i) {
+      EXPECT_TRUE(dyn_cast<SCEVConstant>(SE.getPowerOfTwo(Ty, i))
----------------
`{ }` not needed.


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

https://reviews.llvm.org/D144381



More information about the llvm-commits mailing list