[PATCH] D84270: [SCCP] Remove dead switch cases based on range information

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 25 10:39:28 PDT 2020


fhahn added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/SCCP.cpp:658
 
-    if (!CI) {   // Overdefined or unknown condition?
-      // All destinations are executable!
-      if (!SCValue.isUnknownOrUndef())
-        Succs.assign(TI.getNumSuccessors(), true);
+    if (SCValue.isConstantRange()) {
+      const ConstantRange &Range = SCValue.getConstantRange();
----------------
Do we have to exclude constant ranges that may be undef here? Should all successors be feasible in that case?


================
Comment at: llvm/lib/Transforms/Scalar/SCCP.cpp:1866
+    for (auto CI = SI->case_begin(); CI != SI->case_end();) {
+      if (!FeasibleSuccessors.count(CI->getCaseSuccessor())) {
+        BasicBlock *Succ = CI->getCaseSuccessor();
----------------
Recently c++20 style `contains` members have been added to various data types. Might be good to use instead of count here. (https://en.cppreference.com/w/cpp/container/set/contains).

Also, maybe consider using an early continue/increment if the current case is a feasible successor.


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

https://reviews.llvm.org/D84270





More information about the llvm-commits mailing list