[Bug target/85035] New: nios2: adding -fdelete-null-pointer-checks with -O2 enabled

2018-03-22 Thread rvdv at vandewiele dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85035

Bug ID: 85035
   Summary: nios2: adding -fdelete-null-pointer-checks with -O2
enabled
   Product: gcc
   Version: 7.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rvdv at vandewiele dot com
  Target Milestone: ---

Created attachment 43732
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43732&action=edit
source file

The code in attachment reads a 64 bit integer to compare it. 
When loading the first 32 bit, an instruction is used that bypasses the cache.
For the last 32 bit a regular load is used.

The -mno-cache-volatile option is supposed to bypass the cache for volatile
variables. But as you can see, no volatile variables are used in the example.

I have noticed that working code is generated when the
"-fdelete-null-pointer-checks" option is removed.
The O2 option should also enable "-fdelete-null-pointer-checks", so I would
expect the extra "-fdelete-null-pointer-checks" to be redundant. 
This doesn't seem to be the case.

Target: nios2-elf
Configured with: ../../src/gcc-7.3.0/configure --target=nios2-elf --with-newlib
--disable-threads --disable-shared --disable-multilib --disable-nls
--enable-languages=c,c++ --disable-libssp --enable-lto --without-headers
--prefix=/c/gcc/gcc7.3-src/nios2-elf-7.3.0 --with-isl --enable-plugins
Thread model: single
gcc version 7.3.0 (GCC)

build commad:
./7.3.0/bin/nios2-elf-gcc -O2 -fdelete-null-pointer-checks -mno-cache-volatile
-Wall -Wextra -fno-strict-aliasing -fwrapv -save-temps test.cpp -o test.elf

output:
c:/gcc/nios2-elf-mingw/7.3.0/bin/../lib/gcc/nios2-elf/7.3.0/../../../../nios2-elf/bin/ld.exe:
warning: cannot find entry symbol _start; defaulting to 10dc

[Bug target/85035] nios2: adding -fdelete-null-pointer-checks with -O2 enabled

2018-03-23 Thread rvdv at vandewiele dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85035

--- Comment #2 from rvdv at vandewiele dot com ---
That would explain why different code is generated when it is removed. 
I assumed it was always on because the "-Q --help=optimizers" output showed it
to be enabled. 

Does this mean the option is known to produce broken code on Nios2-elf? 
For my platform it is not safe to dereference null pointers and no code or data
resides at address zero. 
Therefore I assumed the option would produce better code. 

Or is it the combination of -mno-cache-volatile and
-fdelete-null-pointer-checks that is the problem?

[Bug target/85035] nios2: adding -fdelete-null-pointer-checks with -O2 enabled

2018-10-29 Thread rvdv at vandewiele dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85035

--- Comment #5 from rvdv at vandewiele dot com ---
Created attachment 44916
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44916&action=edit
assembly output 7.3.0

This is the assembly output i get with 7.3.0 (and as early as 6.1.0)
I have tried it with 8.1.0 and then I get the same output as you did. 
So it seems like it was fixed in 8.1.0