mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
Simplify code by using ConstantInt::getRawValue instead of checking to see
whether the constant is signed or unsigned, then casting git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7252 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -370,8 +370,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
|
||||
if (Constant *Op1 = dyn_cast<Constant>(I.getOperand(1))) {
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
|
||||
const Type *Ty = CI->getType();
|
||||
int64_t Val = Ty->isSigned() ? cast<ConstantSInt>(CI)->getValue() :
|
||||
(int64_t)cast<ConstantUInt>(CI)->getValue();
|
||||
int64_t Val = (int64_t)cast<ConstantInt>(CI)->getRawValue();
|
||||
switch (Val) {
|
||||
case -1: // X * -1 -> -X
|
||||
return BinaryOperator::createNeg(Op0, I.getName());
|
||||
|
@@ -103,11 +103,7 @@ bool SROA::runOnFunction(Function &F) {
|
||||
Instruction *User = cast<Instruction>(*I);
|
||||
if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(User)) {
|
||||
// We now know that the GEP is of the form: GEP <ptr>, 0, <cst>
|
||||
uint64_t Idx;
|
||||
if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(GEPI->getOperand(2)))
|
||||
Idx = CSI->getValue();
|
||||
else
|
||||
Idx = cast<ConstantUInt>(GEPI->getOperand(2))->getValue();
|
||||
uint64_t Idx = cast<ConstantInt>(GEPI->getOperand(2))->getRawValue();
|
||||
|
||||
assert(Idx < ElementAllocas.size() && "Index out of range?");
|
||||
AllocaInst *AllocaToUse = ElementAllocas[Idx];
|
||||
|
@@ -16,9 +16,7 @@
|
||||
#include <set>
|
||||
|
||||
static inline int64_t getConstantValue(const ConstantInt *CPI) {
|
||||
if (const ConstantSInt *CSI = dyn_cast<ConstantSInt>(CPI))
|
||||
return CSI->getValue();
|
||||
return (int64_t)cast<ConstantUInt>(CPI)->getValue();
|
||||
return (int64_t)cast<ConstantInt>(CPI)->getRawValue();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user