[PATCH] D34822: [LVI] Constant-propagate a zero extension of the switch condition value through case edges

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 20 10:55:52 PDT 2017


sanjoy requested changes to this revision.
sanjoy added inline comments.
This revision now requires changes to proceed.


================
Comment at: lib/Analysis/LazyValueInfo.cpp:1397
+        cast<ZExtInst>(Val)->getOperand(0) == Condition) {
+      // Val is an zero extention of the switch condition value.
+      ZeroExtendedCondition = true;
----------------
s/extention/extension/


================
Comment at: lib/Analysis/LazyValueInfo.cpp:1409
+      if (ZeroExtendedCondition) {
+        CaseValue = CaseValue.zext(BitWidth);
+      }
----------------
This is oddly specific to zero extensions.  Can you use some helpers in InstructionSimplify.h to make this more general over other kinds of operations?  Something like: if `Val` has `Condition` as an operand and if `Val` is a `CastInst` or `BinaryOperator` (say), then invoke `SimplifyBinOp` / `SimplifyFBinOp` / `SimplifyCastInst` (depending on the opcode) with the operand that was `Condition` replaced with the appropriate constant.


https://reviews.llvm.org/D34822





More information about the llvm-commits mailing list