* [Bug target/114487] ICE when building libsdl2 on -mfpmath=sse x86 with LTO
2024-03-26 16:04 [Bug target/114487] New: [14 regression] ICE when building libsdl2 on -mfpmath=sse x86 with LTO sjames at gcc dot gnu.org
@ 2024-03-27 8:36 ` rguenth at gcc dot gnu.org
2024-03-27 9:21 ` ubizjak at gmail dot com
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-27 8:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114487
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[14 regression] ICE when |ICE when building libsdl2
|building libsdl2 on |on -mfpmath=sse x86 with
|-mfpmath=sse x86 with LTO |LTO
Known to fail| |12.3.1, 13.2.1, 14.0, 7.5.0
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-03-27
Keywords| |lto
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I can confirm the ICE. We're expanding
;; gamma_4 = SDLTest_RandomUnitFloat ();
(call_insn/u 5 4 6 (set (reg:SF 20 xmm0)
(call (mem:QI (symbol_ref:SI ("SDLTest_RandomUnitFloat") [flags 0x3]
<function_decl 0x7f8b97072200 SDLTest_RandomUnitFloat>) [0
SDLTest_RandomUnitFloat S1 A8])
(const_int 0 [0]))) "testautomation-testautomation_pixels.i":15:17
-1
(expr_list:REG_CALL_DECL (symbol_ref:SI ("SDLTest_RandomUnitFloat") [flags
0x3] <function_decl 0x7f8b97072200 SDLTest_RandomUnitFloat>)
(expr_list:REG_EH_REGION (const_int 0 [0])
(nil)))
(nil))
(insn 6 5 0 (set (reg/v:SF 99 [ gamma ])
(reg:SF 20 xmm0)) "testautomation-testautomation_pixels.i":15:17 -1
(nil))
I'm not sure what's wrong - looks like a target issue to me.
I'll note -mmmx -msse isn't necessary, -msse2 is enough. Likewise -fPIC
isn't required. I've reproduced with -m32 added on x86_64.
GCC 13/12 are also broken the same way and GCC 7 doesn't terminate compiling.
So I'm not sure whether this is a regression (the reduced testcase, that is).
I can't find a version that works.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/114487] ICE when building libsdl2 on -mfpmath=sse x86 with LTO
2024-03-26 16:04 [Bug target/114487] New: [14 regression] ICE when building libsdl2 on -mfpmath=sse x86 with LTO sjames at gcc dot gnu.org
2024-03-27 8:36 ` [Bug target/114487] " rguenth at gcc dot gnu.org
@ 2024-03-27 9:21 ` ubizjak at gmail dot com
2024-03-27 9:33 ` ubizjak at gmail dot com
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ubizjak at gmail dot com @ 2024-03-27 9:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114487
--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Richard Biener from comment #1)
> (insn 6 5 0 (set (reg/v:SF 99 [ gamma ])
> (reg:SF 20 xmm0)) "testautomation-testautomation_pixels.i":15:17 -1
> (nil))
>
> I'm not sure what's wrong - looks like a target issue to me.
We are working with SFmode, so -msse is enough to trigger the bug.
This is known issue. GCC assumes that at least moves of all hard registers are
working, which is not the case when LTO-compiling
testautomation-testautomation_pixels.i with SDL_test_fuzzer.o (that enables and
uses XMM registers via -msse -mfpmath=sse).
It looks to me that the compiler hits this part in function_value_32 when
LTO-compiling:
--cut here--
/* Override FP return register with %xmm0 for local functions when
SSE math is enabled or for functions with sseregparm attribute. */
if ((fn || fntype) && (mode == SFmode || mode == DFmode))
{
int sse_level = ix86_function_sseregparm (fntype, fn, false);
if (sse_level == -1)
{
error ("calling %qD with SSE calling convention without "
"SSE/SSE2 enabled", fn);
sorry ("this is a GCC bug that can be worked around by adding "
"attribute used to function called");
}
else if ((sse_level >= 1 && mode == SFmode)
|| (sse_level == 2 && mode == DFmode))
regno = FIRST_SSE_REG;
}
--cut here--
Adding -msse to the second compilation works OK, removing -mfpmath=sse from the
first compilation also works OK.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/114487] ICE when building libsdl2 on -mfpmath=sse x86 with LTO
2024-03-26 16:04 [Bug target/114487] New: [14 regression] ICE when building libsdl2 on -mfpmath=sse x86 with LTO sjames at gcc dot gnu.org
2024-03-27 8:36 ` [Bug target/114487] " rguenth at gcc dot gnu.org
2024-03-27 9:21 ` ubizjak at gmail dot com
@ 2024-03-27 9:33 ` ubizjak at gmail dot com
2024-03-27 9:35 ` ubizjak at gmail dot com
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ubizjak at gmail dot com @ 2024-03-27 9:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114487
--- Comment #3 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Uroš Bizjak from comment #2)
> Adding -msse to the second compilation works OK, removing -mfpmath=sse from
> the first compilation also works OK.
Which makes this PR a LTO reincarnation of PR66047.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/114487] ICE when building libsdl2 on -mfpmath=sse x86 with LTO
2024-03-26 16:04 [Bug target/114487] New: [14 regression] ICE when building libsdl2 on -mfpmath=sse x86 with LTO sjames at gcc dot gnu.org
` (2 preceding siblings ...)
2024-03-27 9:33 ` ubizjak at gmail dot com
@ 2024-03-27 9:35 ` ubizjak at gmail dot com
2024-03-27 12:57 ` rguenth at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ubizjak at gmail dot com @ 2024-03-27 9:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114487
--- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Uroš Bizjak from comment #3)
> (In reply to Uroš Bizjak from comment #2)
> > Adding -msse to the second compilation works OK, removing -mfpmath=sse from
> > the first compilation also works OK.
>
> Which makes this PR a LTO reincarnation of PR66047.
Please see the FIXME in ix86_function_sseregparm:
/* Refuse to produce wrong code when local function with SSE enabled
is called from SSE disabled function.
FIXME: We need a way to detect these cases cross-ltrans partition
and avoid using SSE calling conventions on local functions called
from function with SSE disabled. For now at least delay the
warning until we know we are going to produce wrong code.
See PR66047 */
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/114487] ICE when building libsdl2 on -mfpmath=sse x86 with LTO
2024-03-26 16:04 [Bug target/114487] New: [14 regression] ICE when building libsdl2 on -mfpmath=sse x86 with LTO sjames at gcc dot gnu.org
` (3 preceding siblings ...)
2024-03-27 9:35 ` ubizjak at gmail dot com
@ 2024-03-27 12:57 ` rguenth at gcc dot gnu.org
2024-03-27 13:01 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-27 12:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114487
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hubicka at gcc dot gnu.org,
| |rguenth at gcc dot gnu.org
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Ah. But note in this case we only have a single ltrans unit. We might be
confused by the fact that wrong prototype will result in a
call through a float(*)() type while the actual local function doesn't
use any FP registers and has void return.
OTOH the 'void' can be exchanged for 'float' in SDL_test_fuzzer.i and the
issue still reproduces (with a single LTRANS unit).
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/114487] ICE when building libsdl2 on -mfpmath=sse x86 with LTO
2024-03-26 16:04 [Bug target/114487] New: [14 regression] ICE when building libsdl2 on -mfpmath=sse x86 with LTO sjames at gcc dot gnu.org
` (4 preceding siblings ...)
2024-03-27 12:57 ` rguenth at gcc dot gnu.org
@ 2024-03-27 13:01 ` rguenth at gcc dot gnu.org
2024-03-27 23:33 ` sjames at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-27 13:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114487
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
I'd say ix86_function_sseregparm should be decided at a specific point and
recorded for later use. Alternatively there needs to be a (target) IPA
phase where we can mark functions we cannot turn into sseregparm.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/114487] ICE when building libsdl2 on -mfpmath=sse x86 with LTO
2024-03-26 16:04 [Bug target/114487] New: [14 regression] ICE when building libsdl2 on -mfpmath=sse x86 with LTO sjames at gcc dot gnu.org
` (5 preceding siblings ...)
2024-03-27 13:01 ` rguenth at gcc dot gnu.org
@ 2024-03-27 23:33 ` sjames at gcc dot gnu.org
2024-03-27 23:39 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-03-27 23:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114487
--- Comment #7 from Sam James <sjames at gcc dot gnu.org> ---
(You're right, by the way. The original fails with older GCC too. Sorry!)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/114487] ICE when building libsdl2 on -mfpmath=sse x86 with LTO
2024-03-26 16:04 [Bug target/114487] New: [14 regression] ICE when building libsdl2 on -mfpmath=sse x86 with LTO sjames at gcc dot gnu.org
` (6 preceding siblings ...)
2024-03-27 23:33 ` sjames at gcc dot gnu.org
@ 2024-03-27 23:39 ` pinskia at gcc dot gnu.org
2024-03-27 23:44 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-27 23:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114487
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 57823
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57823&action=edit
testcase for non-lto
`-W -Wall -m32 -fwhole-program -march=i686 -O1` is enough
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/114487] ICE when building libsdl2 on -mfpmath=sse x86 with LTO
2024-03-26 16:04 [Bug target/114487] New: [14 regression] ICE when building libsdl2 on -mfpmath=sse x86 with LTO sjames at gcc dot gnu.org
` (7 preceding siblings ...)
2024-03-27 23:39 ` pinskia at gcc dot gnu.org
@ 2024-03-27 23:44 ` pinskia at gcc dot gnu.org
2024-03-27 23:45 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-27 23:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114487
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #8)
> Created attachment 57823 [details]
> testcase for non-lto
>
> `-W -Wall -m32 -fwhole-program -march=i686 -O1` is enough
Note the only difference between this and the reduced LTO case is fix up of
SDLTest_RandomUnitFloat return type so it would be more defined and then the
additions of the #pragma and the use of `-fwhole-program` option instead of LTO
(since LTO does a similar thing).
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/114487] ICE when building libsdl2 on -mfpmath=sse x86 with LTO
2024-03-26 16:04 [Bug target/114487] New: [14 regression] ICE when building libsdl2 on -mfpmath=sse x86 with LTO sjames at gcc dot gnu.org
` (8 preceding siblings ...)
2024-03-27 23:44 ` pinskia at gcc dot gnu.org
@ 2024-03-27 23:45 ` pinskia at gcc dot gnu.org
2024-03-28 4:17 ` sjames at gcc dot gnu.org
2024-03-28 4:17 ` sjames at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-27 23:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114487
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #9)
> (In reply to Andrew Pinski from comment #8)
> > Created attachment 57823 [details]
> > testcase for non-lto
> >
> > `-W -Wall -m32 -fwhole-program -march=i686 -O1` is enough
>
> Note the only difference between this and the reduced LTO case is fix up of
> SDLTest_RandomUnitFloat return type so it would be more defined and then the
> additions of the #pragma and the use of `-fwhole-program` option instead of
> LTO (since LTO does a similar thing).
You can remove -fwhole-program if you make SDLTest_RandomUnitFloat static too
(since that is basically what -fwhole-program is doing after all) and you still
get the failure.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/114487] ICE when building libsdl2 on -mfpmath=sse x86 with LTO
2024-03-26 16:04 [Bug target/114487] New: [14 regression] ICE when building libsdl2 on -mfpmath=sse x86 with LTO sjames at gcc dot gnu.org
` (9 preceding siblings ...)
2024-03-27 23:45 ` pinskia at gcc dot gnu.org
@ 2024-03-28 4:17 ` sjames at gcc dot gnu.org
2024-03-28 4:17 ` sjames at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-03-28 4:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114487
--- Comment #11 from Sam James <sjames at gcc dot gnu.org> ---
I'm going to upload the originals in case it offers more insight because the
return type isn't mismatched there.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/114487] ICE when building libsdl2 on -mfpmath=sse x86 with LTO
2024-03-26 16:04 [Bug target/114487] New: [14 regression] ICE when building libsdl2 on -mfpmath=sse x86 with LTO sjames at gcc dot gnu.org
` (10 preceding siblings ...)
2024-03-28 4:17 ` sjames at gcc dot gnu.org
@ 2024-03-28 4:17 ` sjames at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-03-28 4:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114487
--- Comment #12 from Sam James <sjames at gcc dot gnu.org> ---
Ah, wait, no point with andrew's nicer testcase ;)
^ permalink raw reply [flat|nested] 13+ messages in thread