]> git.ipfire.org Git - thirdparty/gcc.git/commit
expand: Use less costly from sign and zero extensions for values where value range...
authorJakub Jelinek <jakub@redhat.com>
Tue, 10 Jun 2025 18:06:14 +0000 (20:06 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 10 Jun 2025 18:07:39 +0000 (20:07 +0200)
commit2e4688a7202d73baeb4de18ca4591e6b0985f4a4
treee2a02469035dc88c9bf2da12607ef2c2197e7ae7
parent54da199f28da07166a44eae7d53acb9e3abe1306
expand: Use less costly from sign and zero extensions for values where value range says they don't have MSB set [PR120434]

On top of the just posted patch, the following patch attempts to
use value range to see if MSB is known to be false and for scalar integral
extension in that case tries to expand both sign and zero extension and
chooses based on RTX costs the cheaper one (if the costs are the same
uses what it used before, TYPE_UNSIGNED (TREE_TYPE (treeop0)) based.

The patch regresses the gcc.target/i386/pr78103-3.c test, will post
a separate patch for that momentarily (with the intent that if all 3
patches are approved, I'll commit the PR78103 related one before this one).

2025-06-10  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/120434
* expr.cc (expand_expr_real_2) <CASE_CONVERT>: If get_range_pos_neg
at -O2 for scalar integer extension suggests the most significant
bit of op0 is not set, try both unsigned and signed conversion and
choose the cheaper one.  If both are the same cost, choose one
based on TYPE_UNSIGNED (TREE_TYPE (treeop0)).

* gcc.target/i386/pr120434-2.c: New test.
gcc/expr.cc
gcc/testsuite/gcc.target/i386/pr120434-2.c [new file with mode: 0644]