[Bug tree-optimization/125774] [13 Regression] wrong code generated for range check
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 17 21:23:40 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125774
--- Comment #13 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Andrew Pinski
<pinskia@gcc.gnu.org>:
https://gcc.gnu.org/g:8602012548f41b30cea7b1f3b2bbaf9c5691328e
commit r13-10373-g8602012548f41b30cea7b1f3b2bbaf9c5691328e
Author: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Date: Sat Jun 13 14:42:30 2026 -0700
range fold: Fix relation folding of |/& when reversed operands [PR125774]
This showed up in GCC 13 in the original testcase but became latent in GCC
14.
So I created a simple gimple testcase to show the issue.
So what we have is:
_21 = _20 > lower_9;
_22 = lower_9 > _20;
_23 = _21 | _22;
And this would incorrectly be folded into 1 and that is because we treated
one of
those `>` as `<=` rather than as just `<`. This was due to an incorrect use
of relation_negate rather than relation_swap when dealing with swapping the
operands.
Pushed as obvious after a bootstrap/test on x86_64-linux-gnu.
PR tree-optimization/125774
gcc/ChangeLog:
* gimple-range-fold.cc (fold_using_range::relation_fold_and_or):
Use
relation_swap rather than relation_negate when the operands are
exchanged.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr125774-1.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
(cherry picked from commit 905d407ee4b23c749fa00d0cf3b0aed551a07f36)
More information about the Gcc-bugs
mailing list