[PATCH] D144381: [SCEV] Added a util function to SCEV

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 20 21:55:16 PST 2023


mkazantsev requested changes to this revision.
mkazantsev added a comment.
This revision now requires changes to proceed.

Please write a more reasonable patch name



================
Comment at: llvm/include/llvm/Analysis/ScalarEvolution.h:659
+  /// Return a SCEV for the constant 2 with \p Degree power of a specific type.
+  const SCEV *getPowerOfTwo(Type *Ty, long long Degree) {
+    return getConstant(Ty, 1 << Degree);
----------------
1. `Degree -> Power`
2. Does it really have to be `long long`? I mean, it's neither signed nor practically that huge.



================
Comment at: llvm/include/llvm/Analysis/ScalarEvolution.h:660
+  const SCEV *getPowerOfTwo(Type *Ty, long long Degree) {
+    return getConstant(Ty, 1 << Degree);
+  }
----------------
This is incorrect for anything greater than `31`. (1 << 32) is just zero, no matter the type.


================
Comment at: llvm/unittests/Analysis/ScalarEvolutionTest.cpp:1764
+    auto *Sum = SE.getAddExpr(TwoPowerThree, TwoPowerThree, SCEV::FlagNUW);
+    EXPECT_TRUE(
+        SE.isKnownPredicate(ICmpInst::ICMP_ULT, TwoPowerThree, TwoPowerFour));
----------------
Just check that they are constants you expect to see.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144381



More information about the llvm-commits mailing list