]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/119103 - missed overwidening detection for shift
authorRichard Biener <rguenther@suse.de>
Tue, 4 Mar 2025 09:34:39 +0000 (10:34 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 28 Apr 2025 13:08:44 +0000 (15:08 +0200)
commit6901d56fea2132389e9a7ae60b4d9731e6e3c65a
treeeb7a2ae8de688134127c474cf9feddf3e893e030
parent99aa410f5e0a722822698e765ca165e73ca4f637
tree-optimization/119103 - missed overwidening detection for shift

When vectorizing a shift of u16 data by an amount that's known to
be less than 16 we currently fail to emit a vector u16 shift.  The
first reason is that the promotion of the shift amount is hoisted
only by PRE and that cannot preserve range info, the second reason
is that pattern detection doesn't use range info when computing
the precision required for an operation.

The following addresses the first issue by making LIM hoist all
expressions for the pass that runs right before PRE and the
second issue by querying ranges for the shift amount.

PR tree-optimization/119103
* tree-ssa-loop-im.cc (in_loop_pipeline): Globalize.
(compute_invariantness): Override costing when we run
right before PRE and PRE is enabled.
(pass_lim::execute): Adjust.
* tree-vect-patterns.cc (vect_determine_precisions_from_users):
For variable shift amounts use range information.

* gcc.target/i386/pr119103.c: New testcase.
gcc/testsuite/gcc.target/i386/pr119103.c [new file with mode: 0644]
gcc/tree-ssa-loop-im.cc
gcc/tree-vect-patterns.cc