diff --git a/llvm/lib/CodeGen/TypePromotion.cpp b/llvm/lib/CodeGen/TypePromotion.cpp --- a/llvm/lib/CodeGen/TypePromotion.cpp +++ b/llvm/lib/CodeGen/TypePromotion.cpp @@ -192,11 +192,8 @@ } -static bool GenerateSignBits(Value *V) { - if (!isa(V)) - return false; - - unsigned Opc = cast(V)->getOpcode(); +static bool GenerateSignBits(Instruction *I) { + unsigned Opc = I->getOpcode(); return Opc == Instruction::AShr || Opc == Instruction::SDiv || Opc == Instruction::SRem || Opc == Instruction::SExt; } @@ -403,17 +400,14 @@ /// Return whether we can safely mutate V's type to ExtTy without having to be /// concerned with zero extending or truncation. -static bool isPromotedResultSafe(Value *V) { - if (GenerateSignBits(V)) +static bool isPromotedResultSafe(Instruction *I) { + if (GenerateSignBits(I)) return false; - if (!isa(V)) - return true; - - if (!isa(V)) + if (!isa(I)) return true; - return cast(V)->hasNoUnsignedWrap(); + return I->hasNoUnsignedWrap(); } void IRPromoter::ReplaceAllUsersOfWith(Value *From, Value *To) { @@ -798,7 +792,7 @@ if (SafeToPromote.count(I)) return true; - if (isPromotedResultSafe(V) || isSafeWrap(I)) { + if (isPromotedResultSafe(I) || isSafeWrap(I)) { SafeToPromote.insert(I); return true; }