[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

Reid Spencer rspencer at reidspencer.com
Sat Mar 24 11:09:42 PDT 2007


On Sat, 2007-03-24 at 10:06 -0700, Chris Lattner wrote:
> On Mar 24, 2007, at 8:34 AM, Zhou Sheng wrote:
> 
> >
> >
> > Changes in directory llvm/lib/Transforms/Scalar:
> >
> > InstructionCombining.cpp updated: 1.682 -> 1.683
> > ---
> > Log message:
> >
> > Make some codes more efficient.
> >
> > @@ -5813,7 +5816,6 @@
> >        case 16 : SExtType = Type::Int16Ty; break;
> >        case 32 : SExtType = Type::Int32Ty; break;
> >        case 64 : SExtType = Type::Int64Ty; break;
> > -      case 128: SExtType = IntegerType::get(128); break;
> >        default: break;
> >        }
> >        if (SExtType) {
> 
> why did you remove this?

I asked Sheng to remove it because the back ends cannot deal with 128
bit integers.

> 
> > @@ -5833,7 +5835,7 @@
> >            BinaryOperator::createShl(X, ConstantInt::get(Ty,  
> > ShiftDiff));
> >          InsertNewInstBefore(Shift, I);
> >
> > -        APInt Mask(APInt::getAllOnesValue(TypeBits).shl(ShiftAmt2));
> > +        APInt Mask(Ty->getMask().shl(ShiftAmt2));
> 
> You touched many instances of this.  Please make a new  
> APInt::getHighBits method.

The method getHiBits already exists and is used to extrat the N hi bits
from an existing APInt, not construct a new value. I have just committed
a re-organization of the APInt interface (mostly for documentation
purposes) but while I was at it I added three new functions that should
address this need:

  /// Constructs an APInt value that has a contiguous range of bits set.
The
  /// bits from loBit to hiBit will be set. All other bits will be zero.
For
  /// example, with parameters(32, 15, 0) you would get 0x0000FFFF. If
hiBit is
  /// less than loBit then the set bits "wrap". For example, with
  /// parameters (32, 3, 28), you would get 0xF000000F.
  /// @param numBits the intended bit width of the result
  /// @param hiBit the index of the highest bit set.
  /// @param loBit the index of the lowest bit set.
  /// @returns An APInt value with the requested bits set.
  /// @brief Get a value with a block of bits set.
  static APInt getBitsSet(uint32_t numBits, uint32_t hiBit, uint32_t
loBit = 0);

  /// Constructs an APInt value that has the top hiBitsSet bits set.
  /// @param numBits the bitwidth of the result
  /// @param hiBitsSet the number of high-order bits set in the result.
  /// @brief Get a value with high bits set
  static APInt getHighBitsSet(uint32_t numBits, uint32_t hiBitsSet);

  /// Constructs an APInt value that has the bottom loBitsSet bits set.
  /// @param numBits the bitwidth of the result
  /// @param loBitsSet the number of low-order bits set in the result.
  /// @brief Get a value with low bits set
  static APInt getLowBitsSet(uint32_t numBits, uint32_t loBitsSet);

Reid.

> 
> -Chris
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list