Fix flawed logic that was breaking several SPEC benchmarks, including gzip and crafty.
authorChris Lattner <sabre@nondot.org>
Wed, 5 Nov 2003 17:31:36 +0000 (17:31 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 5 Nov 2003 17:31:36 +0000 (17:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9731 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 4a5f1fbcfc3e8dfa5a098681f12eeca05643d9a5..07736b57c2de959fa46c7983078ecdd1cc76f1f5 100644 (file)
@@ -1337,8 +1337,8 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
         // because the source would be zero extended.
         unsigned SrcBits =
           SrcTy == Type::BoolTy ? 1 : SrcTy->getPrimitiveSize()*8;
-        bool HasSignBit = 1ULL << (DestTy->getPrimitiveSize()*8-1);
-        if (ConstVal & ((1ULL << SrcBits)-1)) {
+        bool HasSignBit = ConstVal & (1ULL << (DestTy->getPrimitiveSize()*8-1));
+        if (ConstVal & ~((1ULL << SrcBits)-1)) {
           switch (I.getOpcode()) {
           default: assert(0 && "Unknown comparison type!");
           case Instruction::SetEQ:
@@ -1655,7 +1655,7 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) {
         unsigned AllocElTySize = TD->getTypeSize(AllocElTy);
         const Type *CastElTy = PTy->getElementType();
         unsigned CastElTySize = TD->getTypeSize(CastElTy);
-        
+
         // If the allocation is for an even multiple of the cast type size
         if (CastElTySize && (AllocElTySize % CastElTySize == 0)) {
           Value *Amt = ConstantUInt::get(Type::UIntTy,