forked from OSchip/llvm-project
[TypePromotion] Use Instruction* instead of Value* for a couple functions. NFC
This matches how they are called and allows some isa/cast/dyn_cast to be removed. Differential Revision: https://reviews.llvm.org/D108333
This commit is contained in:
parent
36d8316cc8
commit
c60a4c1ba5
|
@ -192,11 +192,8 @@ public:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool GenerateSignBits(Value *V) {
|
static bool GenerateSignBits(Instruction *I) {
|
||||||
if (!isa<Instruction>(V))
|
unsigned Opc = I->getOpcode();
|
||||||
return false;
|
|
||||||
|
|
||||||
unsigned Opc = cast<Instruction>(V)->getOpcode();
|
|
||||||
return Opc == Instruction::AShr || Opc == Instruction::SDiv ||
|
return Opc == Instruction::AShr || Opc == Instruction::SDiv ||
|
||||||
Opc == Instruction::SRem || Opc == Instruction::SExt;
|
Opc == Instruction::SRem || Opc == Instruction::SExt;
|
||||||
}
|
}
|
||||||
|
@ -403,17 +400,14 @@ bool TypePromotion::shouldPromote(Value *V) {
|
||||||
|
|
||||||
/// Return whether we can safely mutate V's type to ExtTy without having to be
|
/// Return whether we can safely mutate V's type to ExtTy without having to be
|
||||||
/// concerned with zero extending or truncation.
|
/// concerned with zero extending or truncation.
|
||||||
static bool isPromotedResultSafe(Value *V) {
|
static bool isPromotedResultSafe(Instruction *I) {
|
||||||
if (GenerateSignBits(V))
|
if (GenerateSignBits(I))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!isa<Instruction>(V))
|
if (!isa<OverflowingBinaryOperator>(I))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!isa<OverflowingBinaryOperator>(V))
|
return I->hasNoUnsignedWrap();
|
||||||
return true;
|
|
||||||
|
|
||||||
return cast<Instruction>(V)->hasNoUnsignedWrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRPromoter::ReplaceAllUsersOfWith(Value *From, Value *To) {
|
void IRPromoter::ReplaceAllUsersOfWith(Value *From, Value *To) {
|
||||||
|
@ -798,7 +792,7 @@ bool TypePromotion::isLegalToPromote(Value *V) {
|
||||||
if (SafeToPromote.count(I))
|
if (SafeToPromote.count(I))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (isPromotedResultSafe(V) || isSafeWrap(I)) {
|
if (isPromotedResultSafe(I) || isSafeWrap(I)) {
|
||||||
SafeToPromote.insert(I);
|
SafeToPromote.insert(I);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue