[llvm-commits] [llvm] r76232 - in /llvm/trunk: include/llvm/BinaryOperators.h include/llvm/Operator.h lib/Analysis/ScalarEvolution.cpp lib/Analysis/ValueTracking.cpp lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
clattner at apple.com
Fri Jul 17 14:28:10 PDT 2009
On Jul 17, 2009, at 1:47 PM, Dan Gohman wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=76232&view=rev
> Log:
> Add a new Operator class, for handling Instructions and ConstantExprs
> in a convenient manner, factoring out some common code from
> InstructionCombining and ValueTracking. Move the contents of
> BinaryOperators.h into Operator.h and use Operator to generalize them
> to support ConstantExprs as well as Instructions.
Nice, this is very elegant.
> +/// OverflowingBinaryOperator - Utility class for integer
> arithmetic operators
> +/// which may exhibit overflow - Add, Sub, and Mul.
> +///
> +class OverflowingBinaryOperator : public Operator {
> +public:
> + /// hasNoSignedOverflow - Test whether this operation is known to
> never
> + /// undergo signed overflow.
> + bool hasNoSignedOverflow() const {
> + return SubclassOptionalData & (1 << 0);
> + }
> + void setHasNoSignedOverflow(bool B) {
> + SubclassOptionalData = (SubclassOptionalData & ~(1 << 0)) | (B
> << 0);
> + }
> +
> + /// hasNoUnsignedOverflow - Test whether this operation is known
> to never
> + /// undergo unsigned overflow.
> + bool hasNoUnsignedOverflow() const {
> + return SubclassOptionalData & (1 << 1);
> + }
> + void setHasNoUnsignedOverflow(bool B) {
> + SubclassOptionalData = (SubclassOptionalData & ~(1 << 1)) | (B
> << 1);
> + }
Cool. Being able to model signed and unsigned overflow independently
is nice.
> +/// UDivOperator - An Operator with opcode Instruction::UDiv.
Out of curiosity, why just udiv? sdiv is the operator used for
pointer subtraction types of things, and it is always an exact
division. I'm not sure what exact udiv is used for.
-Chris
More information about the llvm-commits
mailing list