[llvm] r216250 - ValueTracking: Figure out more bits when looking at add/sub

Jay Foad jay.foad at gmail.com
Wed Aug 27 08:29:28 PDT 2014


Hi David,

> +  // Compute known bits of the carry.
> +  APInt CarryKnownZero = ~(PossibleSumZero ^ LHSKnownZero ^ KnownZero2);
> +  APInt CarryKnownOne = PossibleSumOne ^ LHSKnownOne ^ KnownOne2;
> +
> +  // Compute set of known bits (where all three relevant bits are known).
> +  APInt LHSKnown = LHSKnownZero | LHSKnownOne;
> +  APInt RHSKnown = KnownZero2 | KnownOne2;
> +  APInt CarryKnown = CarryKnownZero | CarryKnownOne;
> +  APInt Known = LHSKnown & RHSKnown & CarryKnown;
> +
> +  assert((PossibleSumZero & Known) == (PossibleSumOne & Known) &&
> +         "known bits of sum differ");

I think you can simplify this lot to:

  // Compute set of known bits (where all three relevant bits are known).
  APInt LHSKnown = LHSKnownZero | LHSKnownOne;
  APInt RHSKnown = KnownZero2 | KnownOne2;
  APInt Known = LHSKnown & RHSKnown & ~(PossibleSumZero ^ PossibleSumOne);

Jay.



More information about the llvm-commits mailing list