unswitch: Fold case label lo/hi values to index type [PR105770]
authorJakub Jelinek <jakub@redhat.com>
Wed, 1 Jun 2022 12:00:49 +0000 (14:00 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 1 Jun 2022 12:00:49 +0000 (14:00 +0200)
commit0d5cc976a36af07c9790c38a99a0b98110c89795
tree7564d5ff9124d49fed52f08a1d2dc70c77070d62
parent45c8523dd3e50daa5f0bba040099fdfd2ad1aaaa
unswitch: Fold case label lo/hi values to index type [PR105770]

The following testcase ICEs because we use different types in comparison,
idx has int type, while CASE_LOW has char type.

While I believe all CASE_{LOW,HIGH} in the same switch have to use the same
or compatible type, the index expression can have a promoted type as happens
in this testcase.  Other spots that handle switches do such foldings too.

2022-06-01  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/105770
* tree-ssa-loop-unswitch.cc (find_unswitching_predicates_for_bb): Cast
CASE_LOW and CASE_HIGH to TREE_TYPE (idx) before comparisons with idx.

* gcc.dg/pr105770.c: New test.
gcc/testsuite/gcc.dg/pr105770.c [new file with mode: 0644]
gcc/tree-ssa-loop-unswitch.cc