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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 25 11:49:46 PDT 2020


nikic marked an inline comment as done.
nikic 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();
----------------
fhahn wrote:
> Do we have to exclude constant ranges that may be undef here? Should all successors be feasible in that case?
Depends on how conservative we want to be :) Per langref, switch on undef is UB. In practical terms, I would expect the situation for switch to be less problematic than for br, because we generally don't create switches "out of thin air", e.g. loop unswitch does not create switch statements.


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

https://reviews.llvm.org/D84270





More information about the llvm-commits mailing list