public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97255] New: Vectorizer gives a boolean a value of 255
@ 2020-09-30 12:45 iwans at xilinx dot com
2020-09-30 14:12 ` [Bug c++/97255] [8/9/10/11 Regression] " marxin at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: iwans at xilinx dot com @ 2020-09-30 12:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97255
Bug ID: 97255
Summary: Vectorizer gives a boolean a value of 255
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: iwans at xilinx dot com
Target Milestone: ---
Created attachment 49292
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49292&action=edit
Minimal file demonstrating bug
Here is a godbolt link demonstrating the bug: https://godbolt.org/z/jK8Wsz
The following function with -O3 assigns a value of 255 to variables in the out
array. Building with -O3 -fno-tree-vectorize allows the code to execute
correctly
void
logicalOr(Array< char, 4 > in1[60],
Array< bool, 4 > out[60])
{
for (unsigned k0 = 0u; k0 < 60u; ++k0) {
Array< char, 4 > in1m = in1[k0];
Array< bool, 4 > x;
for (unsigned k1 = 0u; k1 < 4u; ++k1) {
char in1s = in1m[k1];
x[k1] = in1s != char(0) || in1s != char(0);
}
out[k0] = x;
}
}
build the attached cpp file (it has no #includes) with
(Buggy)
gcc -O3 vectorizedBool.cpp
./a.out
echo $? // correct value is 1. Actually returns 255
(Not buggy)
gcc -O3 -fno-tree-vectorize vectorizedBool.cpp
./a.out
echo $? // correct value is 1. returns 1
Here is some output from -v
COLLECT_GCC=/opt/compiler-explorer/gcc-10.2.0/bin/g++
Target: x86_64-linux-gnu
Configured with: ../gcc-10.2.0/configure
--prefix=/opt/compiler-explorer/gcc-build/staging --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-bootstrap
--enable-multiarch --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --enable-clocale=gnu
--enable-languages=c,c++,fortran,ada,go,d --enable-ld=yes --enable-gold=yes
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-linker-build-id
--enable-lto --enable-plugins --enable-threads=posix
--with-pkgversion=Compiler-Explorer-Build
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (Compiler-Explorer-Build)
COLLECT_GCC_OPTIONS='-fdiagnostics-color=always' '-g' '-o' './output.s'
'-masm=intel' '-S' '-v' '-O3' '-g' '-Wall' '-Wextra' '-fno-strict-aliasing'
'-fwrapv' '-fno-aggressive-loop-optimizations' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
/opt/compiler-explorer/gcc-10.2.0/bin/../libexec/gcc/x86_64-linux-gnu/10.2.0/cc1plus
-quiet -v -imultiarch x86_64-linux-gnu -iprefix
/opt/compiler-explorer/gcc-10.2.0/bin/../lib/gcc/x86_64-linux-gnu/10.2.0/
-D_GNU_SOURCE <source> -quiet -dumpbase example.cpp -masm=intel -mtune=generic
-march=x86-64 -auxbase-strip ./output.s -g -g -O3 -Wall -Wextra -version
-fdiagnostics-color=always -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations -o ./output.s
GNU C++14 (Compiler-Explorer-Build) version 10.2.0 (x86_64-linux-gnu)
compiled by GNU C version 7.5.0, GMP version 6.1.0, MPFR version 3.1.4,
MPC version 1.0.3, isl version isl-0.18-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/97255] [8/9/10/11 Regression] Vectorizer gives a boolean a value of 255
2020-09-30 12:45 [Bug c++/97255] New: Vectorizer gives a boolean a value of 255 iwans at xilinx dot com
@ 2020-09-30 14:12 ` marxin at gcc dot gnu.org
2020-09-30 15:01 ` [Bug tree-optimization/97255] " rguenth at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-09-30 14:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97255
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-09-30
CC| |marxin at gcc dot gnu.org,
| |rguenth at gcc dot gnu.org
Ever confirmed|0 |1
Summary|Vectorizer gives a boolean |[8/9/10/11 Regression]
|a value of 255 |Vectorizer gives a boolean
| |a value of 255
Keywords| |wrong-code
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, started with r7-717-geb09cdcb1a8b55b9.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97255] [8/9/10/11 Regression] Vectorizer gives a boolean a value of 255
2020-09-30 12:45 [Bug c++/97255] New: Vectorizer gives a boolean a value of 255 iwans at xilinx dot com
2020-09-30 14:12 ` [Bug c++/97255] [8/9/10/11 Regression] " marxin at gcc dot gnu.org
@ 2020-09-30 15:01 ` rguenth at gcc dot gnu.org
2020-10-01 7:24 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-09-30 15:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97255
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c++ |tree-optimization
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
Target Milestone|--- |8.5
Status|NEW |ASSIGNED
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I will have a look.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97255] [8/9/10/11 Regression] Vectorizer gives a boolean a value of 255
2020-09-30 12:45 [Bug c++/97255] New: Vectorizer gives a boolean a value of 255 iwans at xilinx dot com
2020-09-30 14:12 ` [Bug c++/97255] [8/9/10/11 Regression] " marxin at gcc dot gnu.org
2020-09-30 15:01 ` [Bug tree-optimization/97255] " rguenth at gcc dot gnu.org
@ 2020-10-01 7:24 ` rguenth at gcc dot gnu.org
2020-10-01 10:36 ` [Bug tree-optimization/97255] [8/9/10 " rguenth at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-01 7:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97255
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, so it's SRA that creates the IL that ultimatively confuses the vectorizer.
SRA transforms the bool accesses into unsigned char ones:
_32 = in1s_31 != 0;
- MEM <struct Array> [(bool &)&x].m_arr[1] = _32;
+ _7 = VIEW_CONVERT_EXPR<unsigned char>(_32);
+ x$1_16 = _7;
...
_5 = out_17(D) + _2;
- *_5 = x;
+ MEM <unsigned char> [(struct Array *)_5] = x_15;
+ MEM <unsigned char> [(struct Array *)_5 + 1B] = x$1_16;
+ MEM <unsigned char> [(struct Array *)_5 + 2B] = x$2_23;
+ MEM <unsigned char> [(struct Array *)_5 + 3B] = x$3_28;
we do not recognize the VIEW_CONVERT_EXPR as bool pattern. I have a fix.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97255] [8/9/10 Regression] Vectorizer gives a boolean a value of 255
2020-09-30 12:45 [Bug c++/97255] New: Vectorizer gives a boolean a value of 255 iwans at xilinx dot com
` (2 preceding siblings ...)
2020-10-01 7:24 ` rguenth at gcc dot gnu.org
@ 2020-10-01 10:36 ` rguenth at gcc dot gnu.org
2020-10-12 8:28 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-01 10:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97255
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[8/9/10/11 Regression] |[8/9/10 Regression]
|Vectorizer gives a boolean |Vectorizer gives a boolean
|a value of 255 |a value of 255
Known to work| |11.0
Priority|P3 |P2
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
commit 36e691d3a62145fda1f4a1b3143d215cc113c10a (origin/master, origin/HEAD)
Author: Richard Biener <rguenther@suse.de>
Date: Thu Oct 1 09:29:32 2020 +0200
tree-optimization/97255 - missing vector bool pattern of SRAed bool
SRA tends to use VIEW_CONVERT_EXPR when replacing bool fields with
unsigned char fields. Those are not handled in vector bool pattern
detection causing vector true values to leak. The following fixes
this by turning those into b ? 1 : 0 as well.
2020-10-01 Richard Biener <rguenther@suse.de>
* tree-vect-patterns.c (vect_recog_bool_pattern): Also handle
VIEW_CONVERT_EXPR.
* g++.dg/vect/pr97255.cc: New testcase.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97255] [8/9/10 Regression] Vectorizer gives a boolean a value of 255
2020-09-30 12:45 [Bug c++/97255] New: Vectorizer gives a boolean a value of 255 iwans at xilinx dot com
` (3 preceding siblings ...)
2020-10-01 10:36 ` [Bug tree-optimization/97255] [8/9/10 " rguenth at gcc dot gnu.org
@ 2020-10-12 8:28 ` cvs-commit at gcc dot gnu.org
2020-12-02 12:21 ` [Bug tree-optimization/97255] [8/9 " cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-10-12 8:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97255
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:67baa11f68e72cf562c491a8107bcdf3f1d6fc9b
commit r10-8878-g67baa11f68e72cf562c491a8107bcdf3f1d6fc9b
Author: Richard Biener <rguenther@suse.de>
Date: Thu Oct 1 09:29:32 2020 +0200
tree-optimization/97255 - missing vector bool pattern of SRAed bool
SRA tends to use VIEW_CONVERT_EXPR when replacing bool fields with
unsigned char fields. Those are not handled in vector bool pattern
detection causing vector true values to leak. The following fixes
this by turning those into b ? 1 : 0 as well.
2020-10-01 Richard Biener <rguenther@suse.de>
PR tree-optimization/97255
* tree-vect-patterns.c (vect_recog_bool_pattern): Also handle
VIEW_CONVERT_EXPR.
* g++.dg/vect/pr97255.cc: New testcase.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97255] [8/9 Regression] Vectorizer gives a boolean a value of 255
2020-09-30 12:45 [Bug c++/97255] New: Vectorizer gives a boolean a value of 255 iwans at xilinx dot com
` (4 preceding siblings ...)
2020-10-12 8:28 ` cvs-commit at gcc dot gnu.org
@ 2020-12-02 12:21 ` cvs-commit at gcc dot gnu.org
2021-03-17 11:14 ` [Bug tree-optimization/97255] [8 " cvs-commit at gcc dot gnu.org
2021-03-17 11:16 ` rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-02 12:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97255
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:f720a0d776252aac3002a0a9307a96465f1975bd
commit r9-9091-gf720a0d776252aac3002a0a9307a96465f1975bd
Author: Richard Biener <rguenther@suse.de>
Date: Thu Oct 1 09:29:32 2020 +0200
tree-optimization/97255 - missing vector bool pattern of SRAed bool
SRA tends to use VIEW_CONVERT_EXPR when replacing bool fields with
unsigned char fields. Those are not handled in vector bool pattern
detection causing vector true values to leak. The following fixes
this by turning those into b ? 1 : 0 as well.
2020-10-01 Richard Biener <rguenther@suse.de>
PR tree-optimization/97255
* tree-vect-patterns.c (vect_recog_bool_pattern): Also handle
VIEW_CONVERT_EXPR.
* g++.dg/vect/pr97255.cc: New testcase.
(cherry picked from commit 36e691d3a62145fda1f4a1b3143d215cc113c10a)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97255] [8 Regression] Vectorizer gives a boolean a value of 255
2020-09-30 12:45 [Bug c++/97255] New: Vectorizer gives a boolean a value of 255 iwans at xilinx dot com
` (5 preceding siblings ...)
2020-12-02 12:21 ` [Bug tree-optimization/97255] [8/9 " cvs-commit at gcc dot gnu.org
@ 2021-03-17 11:14 ` cvs-commit at gcc dot gnu.org
2021-03-17 11:16 ` rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-17 11:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97255
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:87da0caaec663bd427147c04e5784d7843ede96a
commit r8-10806-g87da0caaec663bd427147c04e5784d7843ede96a
Author: Richard Biener <rguenther@suse.de>
Date: Thu Oct 1 09:29:32 2020 +0200
tree-optimization/97255 - missing vector bool pattern of SRAed bool
SRA tends to use VIEW_CONVERT_EXPR when replacing bool fields with
unsigned char fields. Those are not handled in vector bool pattern
detection causing vector true values to leak. The following fixes
this by turning those into b ? 1 : 0 as well.
2020-10-01 Richard Biener <rguenther@suse.de>
PR tree-optimization/97255
* tree-vect-patterns.c (vect_recog_bool_pattern): Also handle
VIEW_CONVERT_EXPR.
* g++.dg/vect/pr97255.cc: New testcase.
(cherry picked from commit f720a0d776252aac3002a0a9307a96465f1975bd)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97255] [8 Regression] Vectorizer gives a boolean a value of 255
2020-09-30 12:45 [Bug c++/97255] New: Vectorizer gives a boolean a value of 255 iwans at xilinx dot com
` (6 preceding siblings ...)
2021-03-17 11:14 ` [Bug tree-optimization/97255] [8 " cvs-commit at gcc dot gnu.org
@ 2021-03-17 11:16 ` rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-03-17 11:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97255
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |8.4.0
Status|ASSIGNED |RESOLVED
Known to work| |8.4.1
Resolution|--- |FIXED
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-03-17 11:16 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-30 12:45 [Bug c++/97255] New: Vectorizer gives a boolean a value of 255 iwans at xilinx dot com
2020-09-30 14:12 ` [Bug c++/97255] [8/9/10/11 Regression] " marxin at gcc dot gnu.org
2020-09-30 15:01 ` [Bug tree-optimization/97255] " rguenth at gcc dot gnu.org
2020-10-01 7:24 ` rguenth at gcc dot gnu.org
2020-10-01 10:36 ` [Bug tree-optimization/97255] [8/9/10 " rguenth at gcc dot gnu.org
2020-10-12 8:28 ` cvs-commit at gcc dot gnu.org
2020-12-02 12:21 ` [Bug tree-optimization/97255] [8/9 " cvs-commit at gcc dot gnu.org
2021-03-17 11:14 ` [Bug tree-optimization/97255] [8 " cvs-commit at gcc dot gnu.org
2021-03-17 11:16 ` rguenth at gcc dot gnu.org
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).