[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure) since r15-6774-g740c84975ceb74

2025-01-13 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

Sam James  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #30 from Sam James  ---
All done. Thank you!

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure) since r15-6774-g740c84975ceb74

2025-01-13 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

--- Comment #29 from GCC Commits  ---
The master branch has been updated by Alexandre Oliva :

https://gcc.gnu.org/g:52e4ede030979d8aff2f88364e1d11c61fb212aa

commit r15-6866-g52e4ede030979d8aff2f88364e1d11c61fb212aa
Author: Alexandre Oliva 
Date:   Mon Jan 13 10:49:51 2025 -0300

[ifcombine] propagate signbit mask to XOR right-hand operand

If a single-bit bitfield takes up the sign bit of a storage unit,
comparing the corresponding bitfield between two objects loads the
storage units, XORs them, converts the result to signed char, and
compares it with zero: ((signed char)(a. ^ c.) >= 0).

fold_truth_andor_for_ifcombine recognizes the compare with zero as a
sign bit test, then it decomposes the XOR into an equality test.

The problem is that, after this decomposition, that figures out the
width of the accessed fields, we apply the sign bit mask to the
left-hand operand of the compare, but we failed to also apply it to
the right-hand operand when both were taken from the same XOR.

This patch fixes that.


for  gcc/ChangeLog

PR tree-optimization/118409
* gimple-fold.cc (fold_truth_andor_for_ifcombine): Apply the
signbit mask to the right-hand XOR operand too.

for  gcc/testsuite/ChangeLog

PR tree-optimization/118409
* gcc.dg/field-merge-20.c: New.

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure) since r15-6774-g740c84975ceb74

2025-01-13 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

Sam James  changed:

   What|Removed |Added

 CC||ro at gcc dot gnu.org

--- Comment #28 from Sam James  ---
*** Bug 118452 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure) since r15-6774-g740c84975ceb74

2025-01-13 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

--- Comment #27 from Sam James  ---
Confirmed it fixes the binutils testsuite too.

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure) since r15-6774-g740c84975ceb74

2025-01-12 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

--- Comment #26 from Sam James  ---
Thanks Alexandre. I'll chuck it in over here as well.

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure) since r15-6774-g740c84975ceb74

2025-01-12 Thread aoliva at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

--- Comment #25 from Alexandre Oliva  ---
Created attachment 60132
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60132&action=edit
candidate patch

Here's what I'm testing.

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure) since r15-6774-g740c84975ceb74

2025-01-12 Thread aoliva at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

Alexandre Oliva  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |aoliva at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

--- Comment #24 from Alexandre Oliva  ---
Mine, thanks

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure) since r15-6774-g740c84975ceb74

2025-01-12 Thread hp at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

--- Comment #23 from Hans-Peter Nilsson  ---
(In reply to Jeffrey A. Law from comment #18)
> m32r, h8300 and iq2000 are all failing execute/20040709-?.c
...aaand MMIX joins the crowd with results at
https://gcc.gnu.org/pipermail/gcc-testresults/2025-January/835093.html

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure) since r15-6774-g740c84975ceb74

2025-01-12 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

Sam James  changed:

   What|Removed |Added

 CC||doko at gcc dot gnu.org

--- Comment #22 from Sam James  ---
*** Bug 118439 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure) since r15-6774-g740c84975ceb74

2025-01-12 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

Sam James  changed:

   What|Removed |Added

   Severity|normal  |blocker

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure)

2025-01-12 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

Sam James  changed:

   What|Removed |Added

 CC||danglin at gcc dot gnu.org

--- Comment #21 from Sam James  ---
*** Bug 118417 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure)

2025-01-11 Thread slyfox at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

Sergei Trofimovich  changed:

   What|Removed |Added

 CC||slyfox at gcc dot gnu.org

--- Comment #19 from Sergei Trofimovich  ---
(In reply to Andrew Pinski from comment #15)
> Created attachment 60112 [details]
> Reduced all the way

Nice test Andrew! Bisect says it started from r15-6774-g740c84975ceb74

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure)

2025-01-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

--- Comment #20 from Andrew Pinski  ---
(In reply to Sergei Trofimovich from comment #19)
> (In reply to Andrew Pinski from comment #15)
> > Created attachment 60112 [details]
> > Reduced all the way
> 
> Nice test Andrew! Bisect says it started from r15-6774-g740c84975ceb74

Most of the credit goes to Sam really. I just took the final step of removing
some minor un-needed things.

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure)

2025-01-11 Thread law at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

Jeffrey A. Law  changed:

   What|Removed |Added

 CC||law at gcc dot gnu.org

--- Comment #18 from Jeffrey A. Law  ---
m32r, h8300 and iq2000 are all failing execute/20040709-?.c, bisected down to
same commits and I strongly suspect are ultimately the same problem.

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure)

2025-01-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

Andrew Pinski  changed:

   What|Removed |Added

 Target||SLOW_BYTE_ACCESS==0
   ||(x86_64)

--- Comment #17 from Andrew Pinski  ---
Note the miscompile only happens for targets were SLOW_BYTE_ACCESS==0 (x86_64).

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure)

2025-01-11 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

Xi Ruoyao  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW
 CC||xry111 at gcc dot gnu.org
   Last reconfirmed||2025-01-11
   Priority|P3  |P1

--- Comment #16 from Xi Ruoyao  ---
(In reply to Andrew Pinski from comment #15)
> Created attachment 60112 [details]
> Reduced all the way

Confirmed then, and I'd say miscompiling gas is a P1.

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure)

2025-01-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

Andrew Pinski  changed:

   What|Removed |Added

  Attachment #60111|0   |1
is obsolete||

--- Comment #15 from Andrew Pinski  ---
Created attachment 60112
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60112&action=edit
Reduced all the way

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure)

2025-01-11 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

Sam James  changed:

   What|Removed |Added

  Attachment #60110|0   |1
is obsolete||

--- Comment #14 from Sam James  ---
Created attachment 60111
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60111&action=edit
tc-i386.c

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure)

2025-01-11 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

Sam James  changed:

   What|Removed |Added

  Attachment #60107|0   |1
is obsolete||

--- Comment #13 from Sam James  ---
Created attachment 60110
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60110&action=edit
tc-i386.c

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure)

2025-01-11 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

--- Comment #12 from Sam James  ---
Bisect says r15-6774-g740c84975ceb74 or r15-6775-gfd4e979d0c6656 (it ICEs for
some commits so can't be more precise).

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure)

2025-01-11 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

Sam James  changed:

   What|Removed |Added

  Attachment #60106|0   |1
is obsolete||

--- Comment #11 from Sam James  ---
Created attachment 60107
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60107&action=edit
tc-i386.c

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure)

2025-01-10 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

--- Comment #10 from Sam James  ---
Created attachment 60106
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60106&action=edit
tc-i386.c

Reducing more, but here's a standalone testcase.

$ gcc tc-i386.c -o tc-i386 -O1 && ./tc-i386
got ret=0
Aborted(core dumped) ./tc-i386

$ gcc tc-i386.c -o tc-i386 -O1 -fdisable-tree-ifcombine && ./tc-i386
cc1: note: disable pass tree-ifcombine for functions in the range of [0,
4294967295]
got ret=1

[Bug tree-optimization/118409] [15 regression] gas miscompiled by ifcombine ("Unsupported broadcast" assemble failure)

2025-01-10 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118409

--- Comment #9 from Sam James  ---
Bad:
```
Breakpoint 2, i386_assemble (line=0x55752532 "vpsubd
-168(%ebp){1to4},%xmm0,%xmm0") at
/home/sam/git/binutils-gdb/gas/config/tc-i386.c:6927
[...]

(gdb) n
6946  end = parse_insn (line, mnemonic, parse_all);
(gdb) p mnemonic
$11 = "\230\vsUUU\000\000%{VUUU\000\000\002\000\000"
(gdb)
```

Good:
```
Breakpoint 5, i386_assemble (line=0x55752532 "vpsubd
-168(%ebp){1to4},%xmm0,%xmm0") at
/home/sam/git/binutils-gdb/gas/config/tc-i386.c:6927
6927  struct pseudo_prefixes orig_pp = pp;
[...]
(gdb) p mnemonic
$4 = "\230\vsUUU\000\000\305{VUUU\000\000\002\000\000"
(gdb)
```