X % -1 == X % 1 == 0
authorChris Lattner <sabre@nondot.org>
Fri, 26 Mar 2004 16:11:24 +0000 (16:11 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 26 Mar 2004 16:11:24 +0000 (16:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12520 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index f2fe8d5eaeddbb99333084b98bfcbc8d9c2b4e60..9b91705110d0966423ba3f84eadf0dd8be34581f 100644 (file)
@@ -808,6 +808,8 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) {
   if (ConstantInt *RHS = dyn_cast<ConstantInt>(I.getOperand(1))) {
     if (RHS->equalsInt(1))  // X % 1 == 0
       return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
+    if (RHS->isAllOnesValue())  // X % -1 == 0
+      return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
 
     // Check to see if this is an unsigned remainder with an exact power of 2,
     // if so, convert to a bitwise and.