[PATCH] D94014: [InstCombine] reduce icmp(ashr X, C1), C2 to sign-bit test

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 11 07:18:50 PST 2021


spatel added a subscriber: nlopes.
spatel added a comment.

In D94014#2490113 <https://reviews.llvm.org/D94014#2490113>, @lebedev.ri wrote:

> alive1 does not actually have a `countLeadingOnes()` precondition

Weird - maybe @nlopes can tell us how this example parses at all then: https://rise4fun.com/Alive/juX1

> (at least as per https://github.com/nunoplopes/alive/blob/master/constants.py),
> so the proof is faulty. `ComputeNumSignBits()`, OTOH, works for me:

...

> Am i holding it wrong, or is this missing some preconditions?

Your example has `lshr`, but we only want to check `ashr` here, right?

Take a look at this one:
https://rise4fun.com/Alive/o8vS

  ERROR: Mismatch in values of i1 %r
  
  Example:
  %x i8 = 0x80 (128, -128)
  C1 i8 = 0x04 (4)
  C2 i8 = 0xFA (250, -6)
  %a i8 = 0xF8 (248, -8)
  Source value: 0x0 (0)
  Target value: 0x1 (1, -1)

This failure does not correspond to the pre-condition, does it? The number of signbits in C2 == 0xFA is 5, and 5 <= 4 is not true.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94014/new/

https://reviews.llvm.org/D94014



More information about the llvm-commits mailing list