]> granicus.if.org Git - llvm/commitdiff
srem doesn't actually have the same resulting sign as its numerator, you could
authorNick Lewycky <nicholas@mxc.ca>
Mon, 28 Feb 2011 09:17:39 +0000 (09:17 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Mon, 28 Feb 2011 09:17:39 +0000 (09:17 +0000)
also have a zero when numerator = denominator. Reverts parts of r126635 and
r126637.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126644 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ValueTracking.cpp
lib/Transforms/InstCombine/InstCombineCompares.cpp
test/Transforms/InstCombine/icmp.ll

index 70d51fac3f287fc5fde6ef8b01efb71e967bc306..7e208692ac2c5a5142e5c9fef08b0f146e621236 100644 (file)
@@ -460,18 +460,6 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask,
         assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
       }
     }
-    if (Mask.isNegative()) {  // We're looking for the sign bit.
-      APInt Mask2 = APInt::getSignBit(BitWidth);
-      KnownZero2 = 0;
-      KnownOne2 = 0;
-      ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, KnownOne2, TD, 
-                        Depth+1);
-      if (KnownOne2[BitWidth-1])
-        KnownOne |= Mask2;
-      if (KnownZero2[BitWidth-1])
-        KnownZero |= Mask2;
-      assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
-    }
     break;
   case Instruction::URem: {
     if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) {
index 79c5d88c6315891de26b46c346ad9315a418d654..fe117c98143f7c7e89469109eeefc6ff45a755be 100644 (file)
@@ -1348,16 +1348,6 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
       }
     }
     break;
-
-  case Instruction::SRem: {
-    bool TrueIfSigned;
-    if (LHSI->hasOneUse() &&
-        isSignBitCheck(ICI.getPredicate(), RHS, TrueIfSigned)) {
-      // srem has the same sign as its dividend so the divisor is irrelevant.
-      return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0), RHS);
-    }
-    break;
-  }
   }
   
   // Simplify icmp_eq and icmp_ne instructions with integer constant RHS.
index f6a18faeb33d40d0a8b2ae32d2bc94f2df557743..ff11bbff77cd34b5bfb26558fb2d64c52c7475ae 100644 (file)
@@ -378,28 +378,18 @@ define i1 @test38(i32 %x, i32 %y, i32 %z) {
   ret i1 %c
 }
 
-; PR9343 #7
-; CHECK: @test39
-; CHECK: ret i1 false
-define i1 @test39(i31 %X, i32 %Y) {
-  %A = zext i31 %X to i32
-  %B = srem i32 %A, %Y
-  %C = icmp slt i32 %B, 0
-  ret i1 %C
-}
-
 ; PR9343 #1
-; CHECK: test40
+; CHECK: test39
 ; CHECK %B = icmp eq i32 %X, 0
-define i1 @test40(i32 %X, i32 %Y) {
+define i1 @test39(i32 %X, i32 %Y) {
   %A = ashr exact i32 %X, %Y
   %B = icmp eq i32 %A, 0
   ret i1 %B
 }
 
-; CHECK: test41
-; CHECK %B = icmp ne i32 %X, 0
-define i1 @test41(i32 %X, i32 %Y) {
+; CHECK: test40
+; CHECK: %B = icmp ne i32 %X, 0
+define i1 @test40(i32 %X, i32 %Y) {
   %A = lshr exact i32 %X, %Y
   %B = icmp ne i32 %A, 0
   ret i1 %B