From 796df73e6e55298195aa4db72a4abf9876d2ec05 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 2 Nov 2002 00:44:25 +0000 Subject: [PATCH] * Remove dead variable * Shift amount is always guaranteed to be 8 bits git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4491 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/InstSelectSimple.cpp | 10 ++++++---- lib/Target/X86/X86ISelSimple.cpp | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp index 7e4f689fe2a..65a7e679836 100644 --- a/lib/Target/X86/InstSelectSimple.cpp +++ b/lib/Target/X86/InstSelectSimple.cpp @@ -153,14 +153,16 @@ ISel::visitShiftInst (ShiftInst & I) { unsigned Op0r = getReg (I.getOperand (0)); unsigned DestReg = getReg (I); - unsigned operandSize = I.getOperand (0)->getType ()->getPrimitiveSize (); + unsigned operandSize = I.getType ()->getPrimitiveSize (); bool isRightShift = (I.getOpcode () == Instruction::Shr); bool isOperandUnsigned = I.getType ()->isUnsigned (); - bool isConstantShiftAmount = (isa (I.getOperand (1))); + if (ConstantUInt *CUI = dyn_cast (I.getOperand (1))) { - // The shift amount is constant. Get its value. - uint64_t shAmt = CUI->getValue (); + // The shift amount is constant, guaranteed to be a ubyte. Get its value. + assert(CUI->getType() == Type::UByteTy && "Shift amount not a ubyte?"); + unsigned char shAmt = CUI->getValue(); + // Emit: reg, shamt (shift-by-immediate opcode "ir" form.) if (isRightShift) { diff --git a/lib/Target/X86/X86ISelSimple.cpp b/lib/Target/X86/X86ISelSimple.cpp index 7e4f689fe2a..65a7e679836 100644 --- a/lib/Target/X86/X86ISelSimple.cpp +++ b/lib/Target/X86/X86ISelSimple.cpp @@ -153,14 +153,16 @@ ISel::visitShiftInst (ShiftInst & I) { unsigned Op0r = getReg (I.getOperand (0)); unsigned DestReg = getReg (I); - unsigned operandSize = I.getOperand (0)->getType ()->getPrimitiveSize (); + unsigned operandSize = I.getType ()->getPrimitiveSize (); bool isRightShift = (I.getOpcode () == Instruction::Shr); bool isOperandUnsigned = I.getType ()->isUnsigned (); - bool isConstantShiftAmount = (isa (I.getOperand (1))); + if (ConstantUInt *CUI = dyn_cast (I.getOperand (1))) { - // The shift amount is constant. Get its value. - uint64_t shAmt = CUI->getValue (); + // The shift amount is constant, guaranteed to be a ubyte. Get its value. + assert(CUI->getType() == Type::UByteTy && "Shift amount not a ubyte?"); + unsigned char shAmt = CUI->getValue(); + // Emit: reg, shamt (shift-by-immediate opcode "ir" form.) if (isRightShift) { -- 2.34.1