llvm.org GIT mirror llvm / 3dc7e49
srem doesn't actually have the same resulting sign as its numerator, you could 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 Nick Lewycky 8 years ago
3 changed file(s) with 5 addition(s) and 37 deletion(s). Raw diff Collapse all Expand all
458458
459459 assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
460460 }
461 }
462 if (Mask.isNegative()) { // We're looking for the sign bit.
463 APInt Mask2 = APInt::getSignBit(BitWidth);
464 KnownZero2 = 0;
465 KnownOne2 = 0;
466 ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, KnownOne2, TD,
467 Depth+1);
468 if (KnownOne2[BitWidth-1])
469 KnownOne |= Mask2;
470 if (KnownZero2[BitWidth-1])
471 KnownZero |= Mask2;
472 assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
473461 }
474462 break;
475463 case Instruction::URem: {
13471347 }
13481348 }
13491349 break;
1350
1351 case Instruction::SRem: {
1352 bool TrueIfSigned;
1353 if (LHSI->hasOneUse() &&
1354 isSignBitCheck(ICI.getPredicate(), RHS, TrueIfSigned)) {
1355 // srem has the same sign as its dividend so the divisor is irrelevant.
1356 return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0), RHS);
1357 }
1358 break;
1359 }
13601350 }
13611351
13621352 // Simplify icmp_eq and icmp_ne instructions with integer constant RHS.
377377 ret i1 %c
378378 }
379379
380 ; PR9343 #7
381 ; CHECK: @test39
382 ; CHECK: ret i1 false
383 define i1 @test39(i31 %X, i32 %Y) {
384 %A = zext i31 %X to i32
385 %B = srem i32 %A, %Y
386 %C = icmp slt i32 %B, 0
387 ret i1 %C
388 }
389
390380 ; PR9343 #1
391 ; CHECK: test40
381 ; CHECK: test39
392382 ; CHECK %B = icmp eq i32 %X, 0
393 define i1 @test40(i32 %X, i32 %Y) {
383 define i1 @test39(i32 %X, i32 %Y) {
394384 %A = ashr exact i32 %X, %Y
395385 %B = icmp eq i32 %A, 0
396386 ret i1 %B
397387 }
398388
399 ; CHECK: test41
400 ; CHECK %B = icmp ne i32 %X, 0
401 define i1 @test41(i32 %X, i32 %Y) {
389 ; CHECK: test40
390 ; CHECK: %B = icmp ne i32 %X, 0
391 define i1 @test40(i32 %X, i32 %Y) {
402392 %A = lshr exact i32 %X, %Y
403393 %B = icmp ne i32 %A, 0
404394 ret i1 %B