From 546516c3c00494b92706b23455961a35d21ebd0d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 7 May 2004 15:35:56 +0000 Subject: [PATCH] Fix PR336: The instcombine pass asserts when visiting load instruction git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13400 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 2266a70b6e6..0ad4ad44da0 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -887,7 +887,7 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) { // if so, convert to a bitwise and. if (ConstantUInt *C = dyn_cast(RHS)) if (uint64_t Val = C->getValue()) // Don't break X % 0 (divide by zero) - if (!(Val & Val-1)) // Power of 2 + if (!(Val & (Val-1))) // Power of 2 return BinaryOperator::create(Instruction::And, I.getOperand(0), ConstantUInt::get(I.getType(), Val-1)); } @@ -2869,7 +2869,8 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { if (const PointerType *SrcTy = dyn_cast(CI->getOperand(0)->getType())) { const Type *SrcPTy = SrcTy->getElementType(); - if (TD->getTypeSize(SrcPTy) == TD->getTypeSize(DestPTy) && + if (SrcPTy->isSized() && DestPTy->isSized() && + TD->getTypeSize(SrcPTy) == TD->getTypeSize(DestPTy) && (SrcPTy->isInteger() || isa(SrcPTy)) && (DestPTy->isInteger() || isa(DestPTy))) { // Okay, we are casting from one integer or pointer type to another of -- 2.34.1