+
Syntax:
+
<result> = udiv <ty> <var1>, <var2> ; yields {ty}:result
+
+
Overview:
+
The 'udiv' instruction returns the quotient of its two
+operands.
+
Arguments:
+
The two arguments to the 'udiv' instruction must be
+integer values. Both arguments must have identical
+types. This instruction can also take packed versions
+of the values in which case the elements must be integers.
+
Semantics:
+
The value produced is the unsigned integer quotient of the two operands. This
+instruction always performs an unsigned division operation, regardless of
+whether the arguments are unsigned or not.
+
Example:
+
<result> = udiv uint 4, %var ; yields {uint}:result = 4 / %var
+
+
+
+
+
Syntax:
+
<result> = sdiv <ty> <var1>, <var2> ; yields {ty}:result
+
+
Overview:
+
The 'sdiv' instruction returns the quotient of its two
+operands.
+
Arguments:
+
The two arguments to the 'sdiv' instruction must be
+integer values. Both arguments must have identical
+types. This instruction can also take packed versions
+of the values in which case the elements must be integers.
+
Semantics:
+
The value produced is the signed integer quotient of the two operands. This
+instruction always performs a signed division operation, regardless of whether
+the arguments are signed or not.
+
Example:
+
<result> = sdiv int 4, %var ; yields {int}:result = 4 / %var
+
+
+
+
Syntax:
-
<result> = div <ty> <var1>, <var2> ; yields {ty}:result
+ <result> = fdiv <ty> <var1>, <var2> ; yields {ty}:result
Overview:
-The 'div' instruction returns the quotient of its two
+
The 'fdiv' instruction returns the quotient of its two
operands.
Arguments:
-The two arguments to the 'div' instruction must be either integer or floating point
-values.
-This instruction can also take packed versions of the values.
-Both arguments must have identical types.
+The two arguments to the 'div' instruction must be
+floating point values. Both arguments must have
+identical types. This instruction can also take packed
+versions of the values in which case the elements must be floating point.
Semantics:
-The value produced is the integer or floating point quotient of the
-two operands.
+The value produced is the floating point quotient of the two operands.
Example:
- <result> = div int 4, %var ; yields {int}:result = 4 / %var
+ <result> = fdiv float 4.0, %var ; yields {float}:result = 4.0 / %var
diff --git a/include/llvm/Analysis/ScalarEvolutionExpander.h b/include/llvm/Analysis/ScalarEvolutionExpander.h
index 36731120696..391c12b2bab 100644
--- a/include/llvm/Analysis/ScalarEvolutionExpander.h
+++ b/include/llvm/Analysis/ScalarEvolutionExpander.h
@@ -140,7 +140,7 @@ namespace llvm {
const Type *Ty = S->getType();
Value *LHS = expandInTy(S->getLHS(), Ty);
Value *RHS = expandInTy(S->getRHS(), Ty);
- return BinaryOperator::createDiv(LHS, RHS, "tmp.", InsertPt);
+ return BinaryOperator::createSDiv(LHS, RHS, "tmp.", InsertPt);
}
Value *visitAddRecExpr(SCEVAddRecExpr *S);
diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h
index 2a546c34824..ba1b6d4fecb 100644
--- a/include/llvm/Analysis/ScalarEvolutionExpressions.h
+++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h
@@ -293,7 +293,7 @@ namespace llvm {
//===--------------------------------------------------------------------===//
- /// SCEVSDivExpr - This class represents a binary unsigned division operation.
+ /// SCEVSDivExpr - This class represents a binary signed division operation.
///
class SCEVSDivExpr : public SCEV {
SCEVHandle LHS, RHS;
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 8c244356d41..3bf935bb5b0 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -543,7 +543,9 @@ public:
static Constant *getAdd(Constant *C1, Constant *C2);
static Constant *getSub(Constant *C1, Constant *C2);
static Constant *getMul(Constant *C1, Constant *C2);
- static Constant *getDiv(Constant *C1, Constant *C2);
+ static Constant *getUDiv(Constant *C1, Constant *C2);
+ static Constant *getSDiv(Constant *C1, Constant *C2);
+ static Constant *getFDiv(Constant *C1, Constant *C2);
static Constant *getRem(Constant *C1, Constant *C2);
static Constant *getAnd(Constant *C1, Constant *C2);
static Constant *getOr(Constant *C1, Constant *C2);
diff --git a/include/llvm/Instruction.def b/include/llvm/Instruction.def
index e298aa4fbb9..91a467cf590 100644
--- a/include/llvm/Instruction.def
+++ b/include/llvm/Instruction.def
@@ -93,45 +93,43 @@ HANDLE_TERM_INST ( 6, Unreachable, UnreachableInst)
HANDLE_BINARY_INST( 7, Add , BinaryOperator)
HANDLE_BINARY_INST( 8, Sub , BinaryOperator)
HANDLE_BINARY_INST( 9, Mul , BinaryOperator)
-HANDLE_BINARY_INST(10, Div , BinaryOperator)
-HANDLE_BINARY_INST(11, Rem , BinaryOperator)
+HANDLE_BINARY_INST(10, UDiv , BinaryOperator)
+HANDLE_BINARY_INST(11, SDiv , BinaryOperator)
+HANDLE_BINARY_INST(12, FDiv , BinaryOperator)
+HANDLE_BINARY_INST(13, Rem , BinaryOperator)
// Logical operators...
-HANDLE_BINARY_INST(12, And , BinaryOperator)
-HANDLE_BINARY_INST(13, Or , BinaryOperator)
-HANDLE_BINARY_INST(14, Xor , BinaryOperator)
+HANDLE_BINARY_INST(14, And , BinaryOperator)
+HANDLE_BINARY_INST(15, Or , BinaryOperator)
+HANDLE_BINARY_INST(16, Xor , BinaryOperator)
// Binary comparison operators...
-HANDLE_BINARY_INST(15, SetEQ , SetCondInst)
-HANDLE_BINARY_INST(16, SetNE , SetCondInst)
-HANDLE_BINARY_INST(17, SetLE , SetCondInst)
-HANDLE_BINARY_INST(18, SetGE , SetCondInst)
-HANDLE_BINARY_INST(19, SetLT , SetCondInst)
-HANDLE_BINARY_INST(20, SetGT , SetCondInst)
- LAST_BINARY_INST(20)
+HANDLE_BINARY_INST(17, SetEQ , SetCondInst)
+HANDLE_BINARY_INST(18, SetNE , SetCondInst)
+HANDLE_BINARY_INST(19, SetLE , SetCondInst)
+HANDLE_BINARY_INST(20, SetGE , SetCondInst)
+HANDLE_BINARY_INST(21, SetLT , SetCondInst)
+HANDLE_BINARY_INST(22, SetGT , SetCondInst)
+ LAST_BINARY_INST(22)
// Memory operators...
- FIRST_MEMORY_INST(21)
-HANDLE_MEMORY_INST(21, Malloc, MallocInst) // Heap management instructions
-HANDLE_MEMORY_INST(22, Free , FreeInst )
-HANDLE_MEMORY_INST(23, Alloca, AllocaInst) // Stack management
-HANDLE_MEMORY_INST(24, Load , LoadInst ) // Memory manipulation instrs
-HANDLE_MEMORY_INST(25, Store , StoreInst )
-HANDLE_MEMORY_INST(26, GetElementPtr, GetElementPtrInst)
- LAST_MEMORY_INST(26)
+ FIRST_MEMORY_INST(23)
+HANDLE_MEMORY_INST(23, Malloc, MallocInst) // Heap management instructions
+HANDLE_MEMORY_INST(24, Free , FreeInst )
+HANDLE_MEMORY_INST(25, Alloca, AllocaInst) // Stack management
+HANDLE_MEMORY_INST(26, Load , LoadInst ) // Memory manipulation instrs
+HANDLE_MEMORY_INST(27, Store , StoreInst )
+HANDLE_MEMORY_INST(28, GetElementPtr, GetElementPtrInst)
+ LAST_MEMORY_INST(28)
// Other operators...
- FIRST_OTHER_INST(27)
-HANDLE_OTHER_INST(27, PHI , PHINode ) // PHI node instruction
-HANDLE_OTHER_INST(28, Cast , CastInst ) // Type cast
-HANDLE_OTHER_INST(29, Call , CallInst ) // Call a function
-
-HANDLE_OTHER_INST(30, Shl , ShiftInst ) // Shift operations
-HANDLE_OTHER_INST(31, Shr , ShiftInst )
-// 32 -> Empty slot used to be used for vanext in llvm 1.5 and before.
-// 33 -> Empty slot used to be used for vaarg in llvm 1.5 and before.
+ FIRST_OTHER_INST(29)
+HANDLE_OTHER_INST(29, PHI , PHINode ) // PHI node instruction
+HANDLE_OTHER_INST(30, Cast , CastInst ) // Type cast
+HANDLE_OTHER_INST(31, Call , CallInst ) // Call a function
+HANDLE_OTHER_INST(32, Shl , ShiftInst ) // Shift operations
+HANDLE_OTHER_INST(33, Shr , ShiftInst )
HANDLE_OTHER_INST(34, Select , SelectInst ) // select instruction
-
HANDLE_OTHER_INST(35, UserOp1, Instruction) // May be used internally in a pass
HANDLE_OTHER_INST(36, UserOp2, Instruction)
HANDLE_OTHER_INST(37, VAArg , VAArgInst ) // vaarg instruction
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h
index 4d745d6c2e4..f4c9ad50987 100644
--- a/include/llvm/Support/PatternMatch.h
+++ b/include/llvm/Support/PatternMatch.h
@@ -112,9 +112,21 @@ inline BinaryOp_match