[PATCH] [InstCombine] Fix visitSwitchInst to use right operand types for sub cstexpr.
David Majnemer
david.majnemer at gmail.com
Tue Dec 16 15:31:50 PST 2014
LGTM with the above changes and one comment (I'd make it inline but parts of the diff are missing).
Would it be reasonable to zext instead of sext if the bits you trimmed off were all zeros?
================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:2119
@@ +2118,3 @@
+ Constant *LHS = cast<Constant>(
+ ConstantExpr::getSExt(CaseVal, Cond->getType()));
+ Constant* NewCaseVal = cast<Constant>(
----------------
ConstantExpr::getSExt returns a Constant *, the cast<Constant> should be redundant.
================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:2120-2121
@@ -2120,1 +2119,4 @@
+ ConstantExpr::getSExt(CaseVal, Cond->getType()));
+ Constant* NewCaseVal = cast<Constant>(
+ ConstantExpr::getSub(LHS, cast<Constant>(AddRHS)));
assert(isa<ConstantInt>(NewCaseVal) &&
----------------
Likewise. Also, please stick the pointer on the RHS.
http://reviews.llvm.org/D6644
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list