[PATCH] D140747: [Transform] Rewrite LowerSwitch using APInt
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 28 18:00:53 PST 2022
arsenm added inline comments.
================
Comment at: llvm/lib/Transforms/Utils/LowerSwitch.cpp:279
+ IntRange Gap = {GapLow, GapHigh};
+ if (GapHigh.sgt(GapLow) && IsInRanges(Gap, UnreachableRanges))
NewUpperBound = LHS.back().High;
----------------
This was >= before
================
Comment at: llvm/lib/Transforms/Utils/LowerSwitch.cpp:330
for (CaseItr J = std::next(I), E = Cases.end(); J != E; ++J) {
- int64_t nextValue = J->Low->getSExtValue();
- int64_t currentValue = I->High->getSExtValue();
- BasicBlock* nextBB = J->BB;
- BasicBlock* currentBB = I->BB;
+ APInt nextValue = J->Low->getValue();
+ APInt currentValue = I->High->getValue();
----------------
const ref?
================
Comment at: llvm/lib/Transforms/Utils/LowerSwitch.cpp:432
+ unsigned BitWidth = Cases[0].Low->getBitWidth();
+ APInt SignedZero(BitWidth, 0, true);
+ DenseMap<BasicBlock *, APInt> Popularity;
----------------
APSint?
================
Comment at: llvm/test/Transforms/LowerSwitch/pr59316.ll:1
+; RUN: opt < %s -passes=lowerswitch
+
----------------
Needs checks
================
Comment at: llvm/test/Transforms/LowerSwitch/pr59316.ll:3
+
+define i64 @f(i1 %0, i128 %1, i64* %2) {
+BB:
----------------
Use opaque pointers
================
Comment at: llvm/test/Transforms/LowerSwitch/pr59316.ll:14
+SW_C: ; preds = %SW_C, %BB
+ br i1 %0, label %BB1, label %SW_C
+
----------------
Don't use anonymous values
================
Comment at: llvm/test/Transforms/LowerSwitch/pr59316.ll:18
+ ret i64 0
+}
----------------
Does this test cover all the paths?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140747/new/
https://reviews.llvm.org/D140747
More information about the llvm-commits
mailing list