match.pd: Add clz(X) == 0 -> (int)X < 0 etc. simpifications [PR94802]
authorJakub Jelinek <jakub@redhat.com>
Thu, 31 Dec 2020 10:09:26 +0000 (11:09 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 31 Dec 2020 10:09:26 +0000 (11:09 +0100)
commitd2eb616a0f7bea78164912aa438c29fe1ef5774a
treee8a936a3ca8918db0ea67a25b389229d551e53b8
parent8f12ce2ea3be12de4f83d3c419bdb1dc5036b202
match.pd: Add clz(X) == 0 -> (int)X < 0 etc. simpifications [PR94802]

The following patch adds some clz simplifications.  If
clz is 0, then the MSB of the argument is set, and if clz is prec-1, then
the argument is 1.

2020-12-31  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/94802
* match.pd (clz(X) == 0 -> (int)X < 0): New simplification.
(clz(X) == (prec-1) -> X == 1): Likewise.

* gcc.dg/tree-ssa/pr94802-1.c: New test.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/pr94802-1.c [new file with mode: 0644]