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

            Bug ID: 121311
           Summary: [16 Regression][gcn] Bootstrap fails in
                    testsuite/selftests since r16-2614-g965564eafb721f:
                    simplify-rtx.cc:8732: test_scalar_int_ext_ops: FAIL:
                    ASSERT_RTX_EQ
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: ams at gcc dot gnu.org, rsandifo at gcc dot gnu.org
  Target Milestone: ---
            Target: gcn

Bisecting points to:

commit r16-2614-g965564eafb721f8000013a3112f1bba8d8fae32b
commit 965564eafb721f8000013a3112f1bba8d8fae32b (HEAD)
Author: Richard Sandiford
Date:   Tue Jul 29 15:58:34 2025 +0100

    simplify-rtx: Simplify subregs of logic ops

    This patch adds a new rule for distributing lowpart subregs through
    ANDs, IORs, and XORs with a constant, in cases where one of the terms
    then disappears.  For example:

      (lowart-subreg:QI (and:HI x 0x100))

    simplifies to zero and

      (lowart-subreg:QI (and:HI x 0xff))

    simplifies to (lowart-subreg:QI x).

    This would often be handled at some point using nonzero bits.  However,
    the specific case I want the optimisation for is SVE predicates,
    where nonzero bit tracking isn't currently an option.  Specifically:
    the predicate modes VNx8BI, VNx4BI and VNx2BI have the same size as
    VNx16BI, but treat only every second, fourth, or eighth bit as
    significant.  Thus if we have:

      (subreg:VNx8BI (and:VNx16BI x C))

    where C is the repeating constant { 1, 0, 1, 0, ... }, then the
    AND only clears bits that are made insignificant by the subreg,
    and so the result is equal to (subreg:VNx8BI x).  Later patches
    rely on this.

    gcc/
            * simplify-rtx.cc (simplify_context::simplify_subreg): Distribute
            lowpart subregs through AND/IOR/XOR, if doing so eliminates one
            of the terms.
            (test_scalar_int_ext_ops): Add some tests of the above for
integers.
            * config/aarch64/aarch64.cc (aarch64_test_sve_folding): Likewise
            add tests for predicate modes.

* * *

Building GCN (--enable-as-accelerator-for=x86_64-pc-linux-gnu
              --target=amdgcn-amdhsa)
fails in the selftest step directly after building the actual compiler with:


LC_ALL=C GCC_COLORS=
/home/tob/projects/build-gcc-trunk-offload-amdgcn/./gcc/xgcc
-B/home/tob/projects/build-gcc-trunk-offload-amdgcn/./gcc/  -xc -nostdinc
/dev/null -S -o /dev/null
-fself-test=/home/tob/repos/gcc/gcc/testsuite/selftests

/home/tob/repos/gcc/gcc/simplify-rtx.cc:8732: test_scalar_int_ext_ops:
FAIL: ASSERT_RTX_EQ (
lowpart_subreg (smode, simplify_gen_binary (XOR, bmode, bsubreg, smask),
bmode),
lowpart_subreg (smode, gen_rtx_NOT (bmode, bsubreg), bmode))

  expected: (not:SI (reg:SI 698))
  actual: (subreg:SI (not:DI (subreg:DI (reg:SI 698) 0)) 0)

cc1: internal compiler error: in assert_rtx_eq_at, at selftest-rtl.cc:57

0x20fe6af internal_error(char const*, ...)
        /home/tob/repos/gcc/gcc/diagnostic-global-context.cc:534
0x9eda51 fancy_abort(char const*, int, char const*)
        /home/tob/repos/gcc/gcc/diagnostics/context.cc:1640
0x1105f34 selftest::assert_rtx_eq_at(selftest::location const&, char const*,
rtx_def*, rtx_def*)
        /home/tob/repos/gcc/gcc/selftest-rtl.cc:57
0x1121b11 test_scalar_int_ext_ops
        /home/tob/repos/gcc/gcc/simplify-rtx.cc:8732
0x11242a0 test_scalar_ops
        /home/tob/repos/gcc/gcc/simplify-rtx.cc:8873
0x11242a0 selftest::simplify_rtx_cc_tests()
        /home/tob/repos/gcc/gcc/simplify-rtx.cc:9455
0x1ff1072 selftest::run_tests()
        /home/tob/repos/gcc/gcc/selftest-run-tests.cc:121
0x114de4a toplev::run_self_tests()
        /home/tob/repos/gcc/gcc/toplev.cc:2275

Reply via email to