public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/94467] New: [10 Regression] wrong code with -mavx and ssse3 builtins
@ 2020-04-03 10:55 zsojka at seznam dot cz
2020-04-03 11:18 ` [Bug target/94467] " rguenth at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: zsojka at seznam dot cz @ 2020-04-03 10:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94467
Bug ID: 94467
Summary: [10 Regression] wrong code with -mavx and ssse3
builtins
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: zsojka at seznam dot cz
Target Milestone: ---
Host: x86_64-pc-linux-gnu
Created attachment 48180
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48180&action=edit
reduced testcase
Output:
$ x86_64-pc-linux-gnu-gcc -O -mssse3 testcase.c && ./a.out
$ x86_64-pc-linux-gnu-gcc -O -mavx testcase.c && ./a.out
Aborted
__builtin_ia32_pavgb() doesn't seem to be generated with -mavx.
$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r10-7481-20200331151333-gf14b41d2712-checking-yes-rtl-df-extra-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/10.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--with-cloog --with-ppl --with-isl --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu
--with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r10-7481-20200331151333-gf14b41d2712-checking-yes-rtl-df-extra-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.0.1 20200331 (experimental) (GCC)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/94467] [10 Regression] wrong code with -mavx and ssse3 builtins
2020-04-03 10:55 [Bug target/94467] New: [10 Regression] wrong code with -mavx and ssse3 builtins zsojka at seznam dot cz
@ 2020-04-03 11:18 ` rguenth at gcc dot gnu.org
2020-04-03 11:19 ` rguenth at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-04-03 11:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94467
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Host|x86_64-pc-linux-gnu |
Ever confirmed|0 |1
Last reconfirmed| |2020-04-03
Target Milestone|--- |10.0
Target| |x86_64-*-* i?86-*-*
Keywords| |needs-bisection
Status|UNCONFIRMED |NEW
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. Some mmx-with-sse fallout.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/94467] [10 Regression] wrong code with -mavx and ssse3 builtins
2020-04-03 10:55 [Bug target/94467] New: [10 Regression] wrong code with -mavx and ssse3 builtins zsojka at seznam dot cz
2020-04-03 11:18 ` [Bug target/94467] " rguenth at gcc dot gnu.org
@ 2020-04-03 11:19 ` rguenth at gcc dot gnu.org
2020-04-03 11:35 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-04-03 11:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94467
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note using __builtin_ia32_* directly is discouraged. A testcase using official
intrinsics would be better.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/94467] [10 Regression] wrong code with -mavx and ssse3 builtins
2020-04-03 10:55 [Bug target/94467] New: [10 Regression] wrong code with -mavx and ssse3 builtins zsojka at seznam dot cz
2020-04-03 11:18 ` [Bug target/94467] " rguenth at gcc dot gnu.org
2020-04-03 11:19 ` rguenth at gcc dot gnu.org
@ 2020-04-03 11:35 ` jakub at gcc dot gnu.org
2020-04-03 11:38 ` zsojka at seznam dot cz
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-03 11:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94467
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
Keywords|needs-bisection |
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r10-396-g9c1d1db27d421ab7c5ac1ca9b23cae002f13380e
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/94467] [10 Regression] wrong code with -mavx and ssse3 builtins
2020-04-03 10:55 [Bug target/94467] New: [10 Regression] wrong code with -mavx and ssse3 builtins zsojka at seznam dot cz
` (2 preceding siblings ...)
2020-04-03 11:35 ` jakub at gcc dot gnu.org
@ 2020-04-03 11:38 ` zsojka at seznam dot cz
2020-04-03 11:42 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: zsojka at seznam dot cz @ 2020-04-03 11:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94467
--- Comment #4 from Zdenek Sojka <zsojka at seznam dot cz> ---
(In reply to Richard Biener from comment #2)
> Note using __builtin_ia32_* directly is discouraged. A testcase using
> official intrinsics would be better.
Thanks; I just took the list from
https://gcc.gnu.org/onlinedocs/gcc/x86-Built-in-Functions.html (it has some
mistakes though; I hope to list & report them 'when I have time for that'). I
assume using the intrinsics will be a bit complicated, because creduce will
probably expand/inline them by default to the __builtin_ia32_*() call.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/94467] [10 Regression] wrong code with -mavx and ssse3 builtins
2020-04-03 10:55 [Bug target/94467] New: [10 Regression] wrong code with -mavx and ssse3 builtins zsojka at seznam dot cz
` (3 preceding siblings ...)
2020-04-03 11:38 ` zsojka at seznam dot cz
@ 2020-04-03 11:42 ` jakub at gcc dot gnu.org
2020-04-03 12:07 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-04-03 11:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94467
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Either one has to replace the builtins manually afterwards back with
corresponding intrinsics (something I've done e.g. in the PR94460 patch), or
one could e.g. creduce on mostly preprocessed source where content of
preprocessed #include <x86intrin.h> would be replaced back with the include.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/94467] [10 Regression] wrong code with -mavx and ssse3 builtins
2020-04-03 10:55 [Bug target/94467] New: [10 Regression] wrong code with -mavx and ssse3 builtins zsojka at seznam dot cz
` (4 preceding siblings ...)
2020-04-03 11:42 ` jakub at gcc dot gnu.org
@ 2020-04-03 12:07 ` rguenth at gcc dot gnu.org
2020-04-03 16:27 ` hjl.tools at gmail dot com
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-04-03 12:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94467
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Priority|P3 |P1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/94467] [10 Regression] wrong code with -mavx and ssse3 builtins
2020-04-03 10:55 [Bug target/94467] New: [10 Regression] wrong code with -mavx and ssse3 builtins zsojka at seznam dot cz
` (5 preceding siblings ...)
2020-04-03 12:07 ` rguenth at gcc dot gnu.org
@ 2020-04-03 16:27 ` hjl.tools at gmail dot com
2020-04-03 18:57 ` cvs-commit at gcc dot gnu.org
2020-04-03 18:58 ` hjl.tools at gmail dot com
8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2020-04-03 16:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94467
--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
The bug was introduced by r10-393:
commit 16ed2601ad0a4aa82f11e9df86ea92183f94f979
Author: H.J. Lu <hongjiu.lu@intel.com>
Date: Wed May 15 15:26:19 2019 +0000
i386: Emulate MMX pshufb with SSE version
Emulate MMX version of pshufb with SSE version by masking out the bit 3
of the shuffle control byte. Only SSE register source operand is allowed.
PR target/89021
* config/i386/sse.md (ssse3_pshufbv8qi3): Changed to
define_insn_and_split. Also allow TARGET_MMX_WITH_SSE. Add
SSE emulation.
+(define_insn_and_split "ssse3_pshufbv8qi3"
+ [(set (match_operand:V8QI 0 "register_operand" "=y,x,Yv")
+ (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "0,0,Yv")
+ (match_operand:V8QI 2 "register_mmxmem_operand" "ym,x,Yv")]
+ UNSPEC_PSHUFB))
+ (clobber (match_scratch:V4SI 3 "=X,x,Yv"))] <<< This is an earlyclobber
operand.
+ "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSSE3"
+ "@
+ pshufb\t{%2, %0|%0, %2}
+ #
+ #"
+ "TARGET_MMX_WITH_SSE && reload_completed"
+ [(set (match_dup 3) (match_dup 5))
+ (set (match_dup 3)
+ (and:V4SI (match_dup 3) (match_dup 2)))
+ (set (match_dup 0)
+ (unspec:V16QI [(match_dup 1) (match_dup 4)] UNSPEC_PSHUFB))]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/94467] [10 Regression] wrong code with -mavx and ssse3 builtins
2020-04-03 10:55 [Bug target/94467] New: [10 Regression] wrong code with -mavx and ssse3 builtins zsojka at seznam dot cz
` (6 preceding siblings ...)
2020-04-03 16:27 ` hjl.tools at gmail dot com
@ 2020-04-03 18:57 ` cvs-commit at gcc dot gnu.org
2020-04-03 18:58 ` hjl.tools at gmail dot com
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-03 18:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94467
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:
https://gcc.gnu.org/g:bbcdf9bb3fd04adc59f41e4e1ff6293c84cbecc4
commit r10-7545-gbbcdf9bb3fd04adc59f41e4e1ff6293c84cbecc4
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Fri Apr 3 11:49:10 2020 -0700
x86: Mark scratch operand in ssse3_pshufbv8qi3 as earlyclobber
commit 16ed2601ad0a4aa82f11e9df86ea92183f94f979
Author: H.J. Lu <hongjiu.lu@intel.com>
Date: Wed May 15 15:26:19 2019 +0000
i386: Emulate MMX pshufb with SSE version
has
+(define_insn_and_split "ssse3_pshufbv8qi3"
+ [(set (match_operand:V8QI 0 "register_operand" "=y,x,Yv")
+ (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "0,0,Yv")
+ (match_operand:V8QI 2 "register_mmxmem_operand" "ym,x,Yv")]
+ UNSPEC_PSHUFB))
+ (clobber (match_scratch:V4SI 3 "=X,x,Yv"))]
^^^ There are earlyclobber.
+ "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSSE3"
+ "@
+ pshufb\t{%2, %0|%0, %2}
+ #
+ #"
+ "TARGET_MMX_WITH_SSE && reload_completed"
+ [(set (match_dup 3) (match_dup 5))
+ (set (match_dup 3)
+ (and:V4SI (match_dup 3) (match_dup 2)))
+ (set (match_dup 0)
+ (unspec:V16QI [(match_dup 1) (match_dup 4)] UNSPEC_PSHUFB))]
If input register operand 2 is dead after this insn, RA may choose it
as scratch operand. Since it isn't marked as earlyclobber, operand 2
becomes unused after split and then it gets optimized out. Mark scratch
operand as earlyclobber fixes the issue.
gcc/
PR target/94467
* config/i386/sse.md (ssse3_pshufbv8qi3): Mark scratch operand
as earlyclobber.
gcc/testsuite/
PR target/94467
* gcc.target/i386/pr94467-1.c: New test.
* gcc.target/i386/pr94467-2.c: Likewise.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/94467] [10 Regression] wrong code with -mavx and ssse3 builtins
2020-04-03 10:55 [Bug target/94467] New: [10 Regression] wrong code with -mavx and ssse3 builtins zsojka at seznam dot cz
` (7 preceding siblings ...)
2020-04-03 18:57 ` cvs-commit at gcc dot gnu.org
@ 2020-04-03 18:58 ` hjl.tools at gmail dot com
8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2020-04-03 18:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94467
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
Fixed for GCC 10.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-04-03 18:58 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-03 10:55 [Bug target/94467] New: [10 Regression] wrong code with -mavx and ssse3 builtins zsojka at seznam dot cz
2020-04-03 11:18 ` [Bug target/94467] " rguenth at gcc dot gnu.org
2020-04-03 11:19 ` rguenth at gcc dot gnu.org
2020-04-03 11:35 ` jakub at gcc dot gnu.org
2020-04-03 11:38 ` zsojka at seznam dot cz
2020-04-03 11:42 ` jakub at gcc dot gnu.org
2020-04-03 12:07 ` rguenth at gcc dot gnu.org
2020-04-03 16:27 ` hjl.tools at gmail dot com
2020-04-03 18:57 ` cvs-commit at gcc dot gnu.org
2020-04-03 18:58 ` hjl.tools at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).