+
Syntax:
+
<result> = urem <ty> <var1>, <var2> ; yields {ty}:result
+
+
Overview:
+
The 'urem' instruction returns the remainder from the
+unsigned division of its two arguments.
+
Arguments:
+
The two arguments to the 'urem' instruction must be
+integer values. Both arguments must have identical
+types.
+
Semantics:
+
This instruction returns the unsigned integer remainder of a division.
+This instruction always performs an unsigned division to get the remainder,
+regardless of whether the arguments are unsigned or not.
+
Example:
+
<result> = urem uint 4, %var ; yields {uint}:result = 4 % %var
+
+
+
+
+
Syntax:
-
<result> = rem <ty> <var1>, <var2> ; yields {ty}:result
+ <result> = srem <ty> <var1>, <var2> ; yields {ty}:result
Overview:
-The 'rem' instruction returns the remainder from the
-division of its two operands.
+The 'srem' instruction returns the remainder from the
+signed division of its two operands.
Arguments:
-The two arguments to the 'rem' 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 'srem' instruction must be
+integer values. Both arguments must have identical
+types.
Semantics:
-This returns the remainder of a division (where the result
+
This instruction returns the remainder of a division (where the result
has the same sign as the divisor), not the modulus (where the
result has the same sign as the dividend) of a value. For more
information about the difference, see The
Math Forum.
Example:
- <result> = rem int 4, %var ; yields {int}:result = 4 % %var
+ <result> = srem int 4, %var ; yields {int}:result = 4 % %var
+
+
+
+
+
+
Syntax:
+
<result> = frem <ty> <var1>, <var2> ; yields {ty}:result
+
+
Overview:
+
The 'frem' instruction returns the remainder from the
+division of its two operands.
+
Arguments:
+
The two arguments to the 'frem' instruction must be
+floating point values. Both arguments must have
+identical types.
+
Semantics:
+
This instruction returns the remainder of a division.
+
Example:
+
<result> = frem float 4.0, %var ; yields {float}:result = 4.0 % %var
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index f5fff4d7fb4..e44e07e868c 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -551,7 +551,9 @@ public:
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 *getURem(Constant *C1, Constant *C2); // unsigned rem
+ static Constant *getSRem(Constant *C1, Constant *C2); // signed rem
+ static Constant *getFRem(Constant *C1, Constant *C2);
static Constant *getAnd(Constant *C1, Constant *C2);
static Constant *getOr(Constant *C1, Constant *C2);
static Constant *getXor(Constant *C1, Constant *C2);
diff --git a/include/llvm/Instruction.def b/include/llvm/Instruction.def
index 91a467cf590..4f7f2f54838 100644
--- a/include/llvm/Instruction.def
+++ b/include/llvm/Instruction.def
@@ -90,53 +90,55 @@ HANDLE_TERM_INST ( 6, Unreachable, UnreachableInst)
// Standard binary operators...
FIRST_BINARY_INST( 7)
-HANDLE_BINARY_INST( 7, Add , BinaryOperator)
-HANDLE_BINARY_INST( 8, Sub , BinaryOperator)
-HANDLE_BINARY_INST( 9, Mul , 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)
+HANDLE_BINARY_INST( 7, Add , BinaryOperator)
+HANDLE_BINARY_INST( 8, Sub , BinaryOperator)
+HANDLE_BINARY_INST( 9, Mul , BinaryOperator)
+HANDLE_BINARY_INST(10, UDiv , BinaryOperator)
+HANDLE_BINARY_INST(11, SDiv , BinaryOperator)
+HANDLE_BINARY_INST(12, FDiv , BinaryOperator)
+HANDLE_BINARY_INST(13, URem , BinaryOperator)
+HANDLE_BINARY_INST(14, SRem , BinaryOperator)
+HANDLE_BINARY_INST(15, FRem , BinaryOperator)
// Logical operators...
-HANDLE_BINARY_INST(14, And , BinaryOperator)
-HANDLE_BINARY_INST(15, Or , BinaryOperator)
-HANDLE_BINARY_INST(16, Xor , BinaryOperator)
+HANDLE_BINARY_INST(16, And , BinaryOperator)
+HANDLE_BINARY_INST(17, Or , BinaryOperator)
+HANDLE_BINARY_INST(18, Xor , BinaryOperator)
// Binary comparison operators...
-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)
+HANDLE_BINARY_INST(19, SetEQ , SetCondInst)
+HANDLE_BINARY_INST(20, SetNE , SetCondInst)
+HANDLE_BINARY_INST(21, SetLE , SetCondInst)
+HANDLE_BINARY_INST(22, SetGE , SetCondInst)
+HANDLE_BINARY_INST(23, SetLT , SetCondInst)
+HANDLE_BINARY_INST(24, SetGT , SetCondInst)
+ LAST_BINARY_INST(24)
// Memory operators...
- 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)
+ FIRST_MEMORY_INST(25)
+HANDLE_MEMORY_INST(25, Malloc, MallocInst) // Heap management instructions
+HANDLE_MEMORY_INST(26, Free , FreeInst )
+HANDLE_MEMORY_INST(27, Alloca, AllocaInst) // Stack management
+HANDLE_MEMORY_INST(28, Load , LoadInst ) // Memory manipulation instrs
+HANDLE_MEMORY_INST(29, Store , StoreInst )
+HANDLE_MEMORY_INST(30, GetElementPtr, GetElementPtrInst)
+ LAST_MEMORY_INST(30)
// Other operators...
- 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
-HANDLE_OTHER_INST(38, ExtractElement, ExtractElementInst)// extract from vector.
-HANDLE_OTHER_INST(39, InsertElement, InsertElementInst) // insert into vector
-HANDLE_OTHER_INST(40, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
- LAST_OTHER_INST(40)
+ FIRST_OTHER_INST(31)
+HANDLE_OTHER_INST(31, PHI , PHINode ) // PHI node instruction
+HANDLE_OTHER_INST(32, Cast , CastInst ) // Type cast
+HANDLE_OTHER_INST(33, Call , CallInst ) // Call a function
+HANDLE_OTHER_INST(34, Shl , ShiftInst ) // Shift operations
+HANDLE_OTHER_INST(35, Shr , ShiftInst )
+HANDLE_OTHER_INST(36, Select , SelectInst ) // select instruction
+HANDLE_OTHER_INST(37, UserOp1, Instruction) // May be used internally in a pass
+HANDLE_OTHER_INST(38, UserOp2, Instruction)
+HANDLE_OTHER_INST(39, VAArg , VAArgInst ) // vaarg instruction
+HANDLE_OTHER_INST(40, ExtractElement, ExtractElementInst)// extract from vector.
+HANDLE_OTHER_INST(41, InsertElement, InsertElementInst) // insert into vector
+HANDLE_OTHER_INST(42, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
+ LAST_OTHER_INST(42)
#undef FIRST_TERM_INST
#undef HANDLE_TERM_INST
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h
index f4c9ad50987..bee416a24e7 100644
--- a/include/llvm/Support/PatternMatch.h
+++ b/include/llvm/Support/PatternMatch.h
@@ -130,9 +130,21 @@ inline BinaryOp_match