[Bug target/121306] [16 Regression] testcase failures after r16-2614-g965564eafb721f on x86_64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121306 Richard Sandiford changed: What|Removed |Added Resolution|--- |FIXED Status|NEW |RESOLVED --- Comment #15 from Richard Sandiford --- Hopefully all fixed now. Please reopen if not.
[Bug target/121306] [16 Regression] testcase failures after r16-2614-g965564eafb721f on x86_64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121306
--- Comment #14 from GCC Commits ---
The trunk branch has been updated by Richard Sandiford :
https://gcc.gnu.org/g:3e6e885beb7097c5c5ee2c48ddb3b0e61f3a1fc7
commit r16-3124-g3e6e885beb7097c5c5ee2c48ddb3b0e61f3a1fc7
Author: Richard Sandiford
Date: Mon Aug 11 09:24:10 2025 +0100
simplify-rtx: Distribute some non-narrowing subregs [PR121306]
In g:965564eafb721f813a3112f1bba8d8fae32b I'd added code
to try distributing non-widening subregs through logic ops,
in cases where that would eliminate a term of the logic op.
For "reasons", this indirectly caused combine to generate:
(set (zero_extract:SI (reg/v:SI 101 [ a ])
(const_int 8 [0x8])
(const_int 8 [0x8]))
(not:SI (sign_extract:SI (reg:SI 107 [ b ])
(const_int 8 [0x8])
(const_int 8 [0x8]
instead of:
(set (zero_extract:SI (reg/v:SI 101 [ a ])
(const_int 8 [0x8])
(const_int 8 [0x8]))
(subreg:SI (not:QI (subreg:QI (sign_extract:SI (reg:SI 107 [ b ])
(const_int 8 [0x8])
(const_int 8 [0x8])) 0)) 0))
for some tests that were intended to match x86's *one_cmplqi_ext_1
(see g:a58d770fa1d17ead3c38417b299cce3f19f392db). However, other more
direct ways of generating the pattern continued to have the unsimplified
(subreg:SI (not:QI (subreg:QI (...:SI ... structure, since that
structure wasn't the focus of the original patch.
This patch tries to tackle that simplification head-on. It's another
case of distributing subregs, but this time for non-narrowing rather
than non-widening subregs. We already do the same distribution for
word_mode:
/* Attempt to simplify WORD_MODE SUBREGs of bitwise expressions. */
if (outermode == word_mode
&& (GET_CODE (op) == IOR || GET_CODE (op) == XOR || GET_CODE (op) ==
AND)
&& SCALAR_INT_MODE_P (innermode))
{
rtx op0 = simplify_subreg (outermode, XEXP (op, 0), innermode, byte);
rtx op1 = simplify_subreg (outermode, XEXP (op, 1), innermode, byte);
if (op0 && op1)
return simplify_gen_binary (GET_CODE (op), outermode, op0, op1);
}
which g:0340177d54d08b6375391ba164a878e6a596275e extended to NOT.
For word_mode, there are (reasonably) no restrictions on the inner
mode other than that it is an integer. Doing word_mode logic ops
should be at least as efficient as subword logic ops (if the target
provides subword ops at all). And word_mode logic ops should be
cheaper than multi-word logic ops.
But here we need the distribution for SImode rather than word_mode
(DImode). The patch therefore extends the word_mode distributions
to non-narrowing subregs in which the two modes occupy the same
number of words. This should hopefully be relatively conservative.
It prevents the new rule from going away from word_mode, and attempting
to convert (say) a QImode subreg of a word_mode AND into a QImode AND.
It should be suitable for both CISCy and RISCy targets, including
those that define WORD_REGISTER_OPERATIONS.
The patch also fixes some overlong lines in related code.
gcc/
PR rtl-optimization/121306
* simplify-rtx.cc (simplify_context::simplify_subreg): Distribute
non-narrowing integer-to-integer subregs through logic ops,
in a similar way to the existing word_mode handling.
[Bug target/121306] [16 Regression] testcase failures after r16-2614-g965564eafb721f on x86_64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121306 --- Comment #13 from H.J. Lu --- (In reply to Sam James from comment #12) > Is this one fixed now, or does it still need Richard S's simplify-rtx patch > (https://inbox.sourceware.org/gcc-patches/[email protected]/)? Need this and https://inbox.sourceware.org/gcc-patches/[email protected]/
[Bug target/121306] [16 Regression] testcase failures after r16-2614-g965564eafb721f on x86_64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121306 --- Comment #12 from Sam James --- Is this one fixed now, or does it still need Richard S's simplify-rtx patch (https://inbox.sourceware.org/gcc-patches/[email protected]/)?
[Bug target/121306] [16 Regression] testcase failures after r16-2614-g965564eafb721f on x86_64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121306
--- Comment #11 from GCC Commits ---
The trunk branch has been updated by Richard Sandiford :
https://gcc.gnu.org/g:5305f84c3be3de9397907dfaf151477579d91c77
commit r16-2789-g5305f84c3be3de9397907dfaf151477579d91c77
Author: Richard Sandiford
Date: Tue Aug 5 14:42:34 2025 +0100
i386: Extend recognition of high-reg rvalues [PR121306]
The i386 high-register patterns used things like:
(match_operator:SWI248 2 "extract_operator"
[(match_operand 0 "int248_register_operand" "Q")
(const_int 8)
(const_int 8)])
to match an extraction of a high register such as AH from AX/EAX/RAX.
This construct is used in contexts where only the low 8 bits of the
value matter. This is either done explicitly using a (subreg:QI ... 0)
or implicitly by assigning to an 8-bit zero_extract destination.
extract_operator therefore matches both sign_extract and zero_extract,
since the signedness of the extension beyond 8 bits is irrelevant.
But the fact that only the low 8 bits of the value are significant
means that a shift right by 8 is as good as an extraction. Shifts
right would already be used for things like:
struct s {
long a:8;
long b:8;
long c:48;
};
struct s f(struct s x, long y, long z) {
x.b = (y & z) >> 8;
return x;
}
but are used more after g:965564eafb721f813a3112f1bba8d8fae32b.
This patch therefore replaces extract_operator with a new predicate
called extract_high_operator that matches both extractions and shifts.
The predicate checks the extraction field and shift amount itself,
so that patterns only need to match the first operand.
Splitters used match_op_dup to preserve the choice of extraction.
But the fact that the extractions (and now shifts) are equivalent
means that we can just as easily canonicalise on one of them.
(In theory, canonicalisation would also promote CSE, although
that's unlikely in practice.) The patch goes for zero_extract,
for consistency with destinations.
gcc/
PR target/121306
* config/i386/predicates.md (extract_operator): Replace with...
(extract_high_operator): ...this new predicate.
* config/i386/i386.md (*cmpqi_ext_1, *cmpqi_ext_2)
(*cmpqi_ext_3, *cmpqi_ext_4, *movstrictqi_ext_1)
(*extzv, *insvqi_2, *extendqi_ext_1)
(*addqi_ext_1_slp, *addqi_ext_1_slp,
*addqi_ext_0)
(*addqi_ext2_0, *addqi_ext_1, *qi_ext_2)
(*subqi_ext_1_slp, *subqi_ext_2_slp,
*subqi_ext_0)
(*subqi_ext2_0, *subqi_ext_1, *testqi_ext_1)
(*testqi_ext_2, *qi_ext_1_slp)
(*qi_ext_2_slp. *qi_ext_0)
(*qi_ext2_0, *qi_ext_1)
(*qi_ext_1_cc, *qi_ext_1_cc)
(*qi_ext_2, *qi_ext_3, *negqi_ext_1)
(*one_cmplqi_ext_1, *ashlqi_ext_1,
*qi_ext_1)
(define_peephole2): Replace uses of extract_operator with
extract_high_operator, matching only the first operand.
Use zero_extract rather than match_op_dup when splitting.
[Bug target/121306] [16 Regression] testcase failures after r16-2614-g965564eafb721f on x86_64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121306 --- Comment #10 from GCC Commits --- The master branch has been updated by H.J. Lu : https://gcc.gnu.org/g:a58d770fa1d17ead3c38417b299cce3f19f392db commit r16-2786-ga58d770fa1d17ead3c38417b299cce3f19f392db Author: H.J. Lu Date: Fri Aug 1 08:34:49 2025 -0700 x86: Update *one_cmplqi_ext_1 After commit 965564eafb721f813a3112f1bba8d8fae32b Author: Richard Sandiford Date: Tue Jul 29 15:58:34 2025 +0100 simplify-rtx: Simplify subregs of logic ops combine generates (set (zero_extract:SI (reg/v:SI 101 [ a ]) (const_int 8 [0x8]) (const_int 8 [0x8])) (not:SI (sign_extract:SI (reg:SI 107 [ b ]) (const_int 8 [0x8]) (const_int 8 [0x8] instead of (set (zero_extract:SI (reg/v:SI 101 [ a ]) (const_int 8 [0x8]) (const_int 8 [0x8])) (subreg:SI (not:QI (subreg:QI (sign_extract:SI (reg:SI 107 [ b ]) (const_int 8 [0x8]) (const_int 8 [0x8])) 0)) 0)) Update *one_cmplqi_ext_1 to support the new pattern. PR target/121306 * config/i386/i386.md (*one_cmplqi_ext_1): Updated to support the new pattern. Signed-off-by: H.J. Lu
[Bug target/121306] [16 Regression] testcase failures after r16-2614-g965564eafb721f on x86_64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121306 --- Comment #9 from Andrew Pinski --- *** Bug 121324 has been marked as a duplicate of this bug. ***
[Bug target/121306] [16 Regression] testcase failures after r16-2614-g965564eafb721f on x86_64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121306 Andrew Pinski changed: What|Removed |Added CC||zsojka at seznam dot cz --- Comment #8 from Andrew Pinski --- *** Bug 121309 has been marked as a duplicate of this bug. ***
[Bug target/121306] [16 Regression] testcase failures after r16-2614-g965564eafb721f on x86_64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121306 --- Comment #7 from Andrew Pinski --- (In reply to Andrew Pinski from comment #6) > I am going to file the selftest issue with -m32 seperately. PR 121308.
[Bug target/121306] [16 Regression] testcase failures after r16-2614-g965564eafb721f on x86_64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121306 --- Comment #6 from Andrew Pinski --- (In reply to H.J. Lu from comment #4) > On x86-64, I also saw > > Running target unix/-m32 > Using /usr/share/dejagnu/baseboards/unix.exp as board description file for > target. > Using /usr/share/dejagnu/config/unix.exp as generic interface file for > target. > Using /export/gnu/import/git/sources/gcc/gcc/testsuite/config/default.exp as > tool-and-target-specific interface file. > Running /export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.dg/dg.exp ... > FAIL: gcc.dg/pr78213.c (internal compiler error: in assert_rtx_eq_at, at > selftest-rtl.cc:57) > FAIL: gcc.dg/pr78213.c dg-regexp 12 not found: "^-fself-test: [0-9]+ > pass\(es\) in [.0-9]+ seconds$|.*: note: self-tests are not enabled in this > build$" > FAIL: gcc.dg/pr78213.c (test for excess errors) I am going to file the selftest issue with -m32 seperately.
[Bug target/121306] [16 Regression] testcase failures after r16-2614-g965564eafb721f on x86_64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121306 --- Comment #5 from Andrew Pinski --- (In reply to H.J. Lu from comment #4) > FAIL: gcc.target/i386/pr115102.c scan-assembler bswaphisi2_lowpart > FAIL: gcc.target/i386/xchg-4.c scan-assembler rolw > FAIL: gcc.target/i386/xchg-4.c scan-assembler-not mov These 3 failures are PR 121298 .
[Bug target/121306] [16 Regression] testcase failures after r16-2614-g965564eafb721f on x86_64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121306 H.J. Lu changed: What|Removed |Added Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed||2025-07-30 --- Comment #4 from H.J. Lu --- On x86-64, I also saw Running target unix/-m32 Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target. Using /usr/share/dejagnu/config/unix.exp as generic interface file for target. Using /export/gnu/import/git/sources/gcc/gcc/testsuite/config/default.exp as tool-and-target-specific interface file. Running /export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.dg/dg.exp ... FAIL: gcc.dg/pr78213.c (internal compiler error: in assert_rtx_eq_at, at selftest-rtl.cc:57) FAIL: gcc.dg/pr78213.c dg-regexp 12 not found: "^-fself-test: [0-9]+ pass\(es\) in [.0-9]+ seconds$|.*: note: self-tests are not enabled in this build$" FAIL: gcc.dg/pr78213.c (test for excess errors) FAIL: gcc.target/i386/pr115102.c scan-assembler bswaphisi2_lowpart FAIL: gcc.target/i386/pr82524-3.c scan-assembler-not movzbl FAIL: gcc.target/i386/xchg-4.c scan-assembler rolw FAIL: gcc.target/i386/xchg-4.c scan-assembler-not mov
[Bug target/121306] [16 Regression] testcase failures after r16-2614-g965564eafb721f on x86_64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121306 Andrew Pinski changed: What|Removed |Added CC||rsandifo at gcc dot gnu.org Version|14.2.0 |16.0 Target Milestone|--- |16.0 Keywords||testsuite-fail
[Bug target/121306] [16 Regression] testcase failures after r16-2614-g965564eafb721f on x86_64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121306 Andrew Pinski changed: What|Removed |Added See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=82524 --- Comment #3 from Andrew Pinski --- pr82524-3.c fails in a similar way.
