]> git.ipfire.org Git - thirdparty/gcc.git/commit
forwprop: More nop-conversion handling [PR123731].
authorRobin Dapp <rdapp@oss.qualcomm.com>
Wed, 21 Jan 2026 07:20:48 +0000 (08:20 +0100)
committerRobin Dapp <rdapp@oss.qualcomm.com>
Thu, 22 Jan 2026 12:29:57 +0000 (13:29 +0100)
commitbadd64289a496c0fdb50f39fc2edeb4d124a8d0d
treefe59997f81135749c555ad795019cc6bd26463ff
parentca5a68ac28013530782f8a1ba021c18de561fa7c
forwprop: More nop-conversion handling [PR123731].

Since relaxing the constraints for permutes in r16-6671 for simplifying
vector constructors there is an additional case to be handled as it
interacts with r16-5561 (that allows nop conversions).

In
  vector(8) short unsigned int _4;
  short int _5;
  vector(4) unsigned int _17;

  _3 = *a_14(D);
  _2 = {_3, { 0, 0, 0, 0 }};
  _4 = VEC_PERM_EXPR <{ 0, 0, 0, 0, 0, 0, 0, 0 }, _2, { 0, 9, 11, 3, 10, 2, 9, 8 }>;
  _5 = BIT_FIELD_REF <_4, 16, 32>;
  d_16 = (unsigned int) _5;
  _17 = {d_16, d_16, d_16, d_16};

we failed to consider that _5 is a signed type and directly converted to
unsigned.

With this patch we do
  _3 = *a_14(D);
  _5 = BIT_FIELD_REF <_3, 16, 48>;
  d_16 = (unsigned int) _5;
  _15 = VEC_PERM_EXPR <_3, _3, { 3, 3, 3, 3 }>;
  _1 = VIEW_CONVERT_EXPR<vector(4) short int>(_15);
  _21 = (vector(4) unsigned int) _1;

where the two conversions can often be done in one instruction.

PR tree-optimization/123731

gcc/ChangeLog:

* tree-ssa-forwprop.cc (simplify_vector_constructor): Handle nop
conversion between during extraction.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/pr123731.c: New test.
gcc/testsuite/gcc.dg/vect/pr123731.c [new file with mode: 0644]
gcc/tree-ssa-forwprop.cc