middle-end/106027 - fix types in needle folding
authorRichard Biener <rguenther@suse.de>
Mon, 20 Jun 2022 11:40:50 +0000 (13:40 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 19 Jul 2022 09:26:34 +0000 (11:26 +0200)
commit71c6baa9abc8c378a1aa913398a8f1a2277946e0
tree28957b574ecd83416e969f0ec53e56eb8ca7fc5d
parent8dd1c404ec77c6d2cdaaf93d219e3250081355c0
middle-end/106027 - fix types in needle folding

The fold_to_nonsharp_ineq_using_bound folding ends up creating invalid
typed IL which confuses later foldings.  The following fixes that.

2022-06-20  Richard Biener  <rguenther@suse.de>

PR middle-end/106027
* fold-const.cc (fold_to_nonsharp_ineq_using_bound): Use the
type of the prevailing comparison for the new comparison type.
(fold_binary_loc): Use proper types for the A < X && A + 1 > Y
to A < X && A >= Y folding.

* gcc.dg/pr106027.c: New testcase.

(cherry picked from commit 713f2fd923442b1be620a44240ddf786ae0ab476)
gcc/fold-const.cc
gcc/testsuite/gcc.dg/pr106027.c [new file with mode: 0644]