match.pd: Optimize X / bool_range_Y to X [PR96094]
authorJakub Jelinek <jakub@redhat.com>
Tue, 15 Dec 2020 21:43:46 +0000 (22:43 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 15 Dec 2020 21:43:46 +0000 (22:43 +0100)
commitd41b097350d3c5d03824ea19520cd3b4430c9e62
treee0b58803d667032af0289c111ccca2f7b02166bb
parent36c9a3fe3f3c200ad3937d00d339b7269cf07adb
match.pd: Optimize X / bool_range_Y to X [PR96094]

When the divisor is bool or has [0, 1] range, as division by
0 is UB, the only remaining option in valid programs is division by 1,
so we can optimize X / bool_range_Y into X.

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

PR tree-optimization/96094
* match.pd (X / bool_range_Y -> X): New simplification.

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