> APIntify the isHighOnes utility function. > Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp > diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.667 > llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.668 > --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.667 Mon > Mar 19 16:10:28 2007 > +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Mar 19 > 16:29:50 2007 > @@ -3491,14 +3491,15 @@ > // isHighOnes - Return true if the constant is of the form 1+0+. > // This is the same as lowones(~X). > static bool isHighOnes(const ConstantInt *CI) { > - uint64_t V = ~CI->getZExtValue(); > - if (~V == 0) return false; // 0's does not match "1+" > + if (CI->getValue() == 0) return false; // 0's does not match "1+"
Why not call isZero() ? > + > + APInt V(~CI->getValue()); > > // There won't be bits set in parts that the type doesn't contain. > - V &= ConstantInt::getAllOnesValue(CI->getType())->getZExtValue(); > + V &= APInt::getAllOnesValue(CI->getType()->getBitWidth()); This is an obvious no-op, please remove it. > - uint64_t U = V+1; // If it is low ones, this should be a power > of two. > - return U && V && (U & V) == 0; > + APInt U(V+1); // If it is low ones, this should be a power of two. > + return (U!=0) && (V!=0) && (U & V) == 0; > } Please change this to ispoweroftwo(V+1), at which point you can drop the isZero check above. -Chris > > /// getICmpCode - Encode a icmp predicate into a three bit mask. > These bits > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits