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

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).