https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123731

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Robin Dapp <[email protected]>:

https://gcc.gnu.org/g:badd64289a496c0fdb50f39fc2edeb4d124a8d0d

commit r16-6976-gbadd64289a496c0fdb50f39fc2edeb4d124a8d0d
Author: Robin Dapp <[email protected]>
Date:   Wed Jan 21 08:20:48 2026 +0100

    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.

Reply via email to