]> git.ipfire.org Git - thirdparty/gcc.git/commit
middle-end/123107 - avoid invalid vector folding
authorRichard Biener <rguenther@suse.de>
Wed, 7 Jan 2026 12:18:42 +0000 (13:18 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 8 Jan 2026 07:51:47 +0000 (08:51 +0100)
commitae0cdb01b08fb4929ef17c534f86cd9fae78e799
treef5e94f609c9d601dd8746f1c17624c2e7d913668
parentbba999a7f330cdf093eb20cace8d562237caeb88
middle-end/123107 - avoid invalid vector folding

We fold (v >> CST) == { 0, 0.. } into v < { 0, 0.. } but fail to
validate that's valid for the target.  The following adds such check,
making sure to apply after IPA (due to offloading) and only when
the original form wasn't valid for the target (like before vector
lowering) or when the new form is.  In particular in this case
we have an equality compare resulting in a non-vector which we
can handle, but a similar LT/GT is never handled.

PR middle-end/123107
* fold-const.cc (fold_binary_loc): Guard (v >> CST) == { 0, 0.. }
to v < { 0, 0.. } folding.

* gcc.dg/torture/pr123107.c: New testcase.
gcc/fold-const.cc
gcc/testsuite/gcc.dg/torture/pr123107.c [new file with mode: 0644]