[Bug tree-optimization/61929] New: Graphite: Banerjee and Omega differ on distance vectors (internal compiler error in compute_affine_dependence)

2014-07-27 Thread gcc at crg4 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61929

Bug ID: 61929
   Summary: Graphite: Banerjee and Omega differ on distance
vectors (internal compiler error in
compute_affine_dependence)
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc at crg4 dot com

-fcheck-data-deps finds a discrepancy between Banerjee and Omega in gcc 4.9
when compiling the latest RIES source. The error message is:

(Number of distance vectors differ: Banerjee has 1, Omega has 2.
Banerjee dist vectors:
  0 
Omega dist vectors:
  0 
  1 
data dependence relation:
(Data Dep: 
#(Data Ref: 
#  bb: 44 
#  stmt: debug_L.555_92 = debug_L;
#  ref: debug_L
#  base_object: MEM[(short int *)&debug_L];
#)
#(Data Ref: 
#  bb: 44 
#  stmt: debug_L = debug_L.568_93;
#  ref: debug_L
#  base_object: MEM[(short int *)&debug_L];
#)
  inner loop index: 0
  loop nest: (1 )
  distance_vector:   0 
  distance_vector:   1 
  direction_vector: =
  direction_vector: +
)
)
ries.c: In function ‘set_debug_opts’:
ries.c:10391:6: internal compiler error: in compute_affine_dependence, at
tree-data-ref.c:4233
 void set_debug_opts(char * str)
  ^
Please submit a full bug report,
with preprocessed source if appropriate.



The RIES source is available at
http://www.mrob.com/pub/ries/src/ries.c.txt
and is self-contained (no .h files etc.).

I can cause the error with
gcc -o ries ries.c -lm -O1 -fcheck-data-deps
but not
gcc -o ries ries.c -lm -O0 -fcheck-data-deps
however I cannot narrow this down to a particular optimization causing the
difficulty since
gcc -o ries ries.c -lm -O1 -fcheck-data-deps -fno-branch-count-reg
-fno-combine-stack-adjustments -fno-compare-elim -fno-cprop-registers
-fno-defer-pop -fno-forward-propagate -fno-guess-branch-probability
-fno-if-conversion -fno-if-conversion2 -fno-inline-functions-called-once
-fno-ipa-profile -fno-ipa-pure-const -fno-ipa-reference -fno-merge-constants
-fno-move-loop-invariants -fno-shrink-wrap -fno-split-wide-types
-fno-tree-bit-ccp -fno-tree-ccp -fno-tree-ch -fno-tree-copy-prop
-fno-tree-copyrename -fno-tree-dce -fno-tree-dominator-opts -fno-tree-dse
-fno-tree-fre -fno-tree-pta -fno-tree-sink -fno-tree-slsr -fno-tree-sra
-fno-tree-ter
still causes the error. It appears that at least one of the Omega and Banerjee
algorithms are incorrect.

I am running
> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.9.1-1ubuntu2~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap
--disable-vtable-verify --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.1 (Ubuntu 4.9.1-1ubuntu2~14.04.3)
> uname -a
Linux zed 3.2.0-56-generic #86-Ubuntu SMP Wed Oct 23 09:20:45 UTC 2013 x86_64
x86_64 x86_64 GNU/Linux

I have no knowledge of either Graphite or RIES; I am merely reporting what
appears to be a bug (indeed, as instructed by gcc itself).

[Bug tree-optimization/61929] Graphite: Banerjee and Omega differ on distance vectors (internal compiler error in compute_affine_dependence)

2014-07-28 Thread gcc at crg4 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61929

Charles Greathouse  changed:

   What|Removed |Added

   Keywords||ice-checking,
   ||ice-on-valid-code
Version|unknown |4.9.1

--- Comment #1 from Charles Greathouse  ---
I'm working on minimizing a testcase now. The file I linked to has about 12,000
lines of code and the current minimized version has 400. I'll continue working
on it until it's hopefully a tenth of that.


[Bug tree-optimization/61929] Graphite: Banerjee and Omega differ on distance vectors (internal compiler error in compute_affine_dependence)

2014-07-28 Thread gcc at crg4 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61929

Charles Greathouse  changed:

   What|Removed |Added

  Known to fail||4.8.3, 4.9.1

--- Comment #2 from Charles Greathouse  ---
Minimal testcase (original function was ries_to_digits):

void generateICE(char *s, int p)
{
int i;
for (i = p; i > 0; i--) {
if (s[i] < '0') s[i-1]--;
}
}


[Bug tree-optimization/61929] Graphite: Banerjee and Omega differ on distance vectors (internal compiler error in compute_affine_dependence)

2014-07-28 Thread gcc at crg4 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61929

--- Comment #3 from Charles Greathouse  ---
This appears to also block -floop-parallelize-all from functioning in these
cases.


[Bug tree-optimization/61929] Graphite: Banerjee and Omega differ on distance vectors (internal compiler error in compute_affine_dependence)

2014-07-29 Thread gcc at crg4 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61929

--- Comment #4 from Charles Greathouse  ---
I now have a testcase for failure with -floop-parallelize-all (without
-fcheck-data-deps). I believe this is the same bug, or at least related,
because this testcase also fails with the previous compile command.

int main() {}
void generateICE2(char *s, int i)
{
for (; i >= 2; i--) s[i] = s[i-1];
}

This fails with

gcc testcase.c -lm -O2 -floop-parallelize-all -floop-nest-optimize

or even

gcc testcase.c -lm -O2 -floop-parallelize-all -floop-nest-optimize
-fno-aggressive-loop-optimizations -fno-align-functions -fno-align-jumps
-fno-align-labels -fno-align-loops -fno-asynchronous-unwind-tables
-fno-branch-count-reg -fno-caller-saves -fno-combine-stack-adjustments
-fno-common -fno-compare-elim -fno-cprop-registers -fno-crossjumping
-fno-cse-follow-jumps -fno-dce -fno-defer-pop -fno-delete-null-pointer-checks
-fno-devirtualize -fno-dse -fno-early-inlining -fno-expensive-optimizations
-fno-forward-propagate -fno-gcse -fno-gcse-lm -fno-guess-branch-probability
-fno-hoist-adjacent-loads -fno-if-conversion -fno-if-conversion2 -fno-inline
-fno-inline-atomics -fno-inline-functions-called-once
-fno-inline-small-functions -fno-ipa-cp -fno-ipa-profile -fno-ipa-pure-const
-fno-ipa-reference -fno-ipa-sra -fno-ira-hoist-pressure -fno-ivopts
-fno-jump-tables -fno-math-errno -fno-merge-constants -fno-move-loop-invariants
-fno-optimize-register-move -fno-optimize-sibling-calls -fno-optimize-strlen
-fno-peephole -fno-peephole2 -fno-prefetch-loop-arrays -fno-regmove
-fno-rename-registers -fno-reorder-blocks -fno-reorder-functions
-fno-rerun-cse-after-loop -fno-sched-critical-path-heuristic
-fno-sched-dep-count-heuristic -fno-sched-group-heuristic -fno-sched-interblock
-fno-sched-last-insn-heuristic -fno-sched-rank-heuristic -fno-sched-spec
-fno-sched-spec-insn-heuristic -fno-sched-stalled-insns-dep
-fno-schedule-insns2 -fno-set-stack-executable -fno-short-enums
-fno-shrink-wrap -fno-signed-zeros -fno-split-ivs-in-unroller
-fno-split-wide-types -fno-strict-aliasing -fno-thread-jumps -fno-trapping-math
-fno-tree-bit-ccp -fno-toplevel-reorder -fno-tree-builtin-call-dce
-fno-tree-ccp -fno-tree-coalesce-vars -fno-tree-copy-prop -fno-tree-copyrename
-fno-tree-cselim -fno-tree-dce -fno-tree-dominator-opts -fno-tree-dse
-fno-tree-forwprop -fno-tree-fre -fno-tree-loop-if-convert -fno-tree-loop-im
-fno-tree-loop-ivcanon -fno-tree-phiprop -fno-tree-pre -fno-tree-pta
-fno-tree-reassoc -fno-tree-scev-cprop -fno-tree-sink -fno-tree-slp-vectorize
-fno-tree-slsr -fno-tree-sra -fno-tree-switch-conversion -fno-tree-tail-merge
-fno-tree-ter -fno-tree-vect-loop-version -fno-tree-vrp -fno-unit-at-a-time
-fno-var-tracking -fno-var-tracking-assignments -fno-web

which is -O2 with everything but floop-parallelize-all -floop-nest-optimize
-ftree-loop-optimize -ftree-ch -fthreadsafe-statics turned off. However the bug
does not appear at -O1 and below even with these options.


[Bug tree-optimization/61929] [Graphite]: Banerjee and Omega differ on distance vectors (internal compiler error in compute_affine_dependence)

2015-06-22 Thread gcc at crg4 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61929

--- Comment #5 from Charles Greathouse  ---
Created attachment 35826
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35826&action=edit
-freport-bug preprocessed file

This is the source file produced by -freport-bug in gcc 5.1.0.


[Bug tree-optimization/61929] [Graphite]: Banerjee and Omega differ on distance vectors (internal compiler error in compute_affine_dependence)

2015-06-22 Thread gcc at crg4 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61929

Charles Greathouse  changed:

   What|Removed |Added

Version|4.9.1   |5.1.0
  Known to fail||5.1.0

--- Comment #6 from Charles Greathouse  ---
The RIES source still produces an ICE in gcc 5.1.0. New minimized testcase for
gcc-5.1:

signed short debug_A;
void generateICE(char *str) {
char d;
while(d = *str) {
if (d=='a') debug_A |= 1;
}
}


[Bug tree-optimization/61929] [Graphite]: Banerjee and Omega differ on distance vectors (internal compiler error in compute_affine_dependence)

2015-06-22 Thread gcc at crg4 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61929

--- Comment #7 from Charles Greathouse  ---
Here's a testcase which fails without -fcheck-data-deps. Run
gcc5.1 testcase.c -O2 -ftree-loop-linear -floop-strip-mine
to reproduce:

typedef struct m {
const char * s1;
const char * s2;
} mystruct;
mystruct arr[52];

void main() {}
void generateICE(void) {
int i;
for(i=0; i<52; i++) {
arr[i].s1 = "";
arr[i].s2 = 0;
}
}


[Bug tree-optimization/61929] [Graphite]: Banerjee and Omega differ on distance vectors (internal compiler error in compute_affine_dependence)

2015-06-22 Thread gcc at crg4 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61929

--- Comment #8 from Charles Greathouse  ---
Full trace for last:

isl_constraint.c:625: expecting integer value
testcase.c: In function ‘generateICE’:
testcase.c:8:6: internal compiler error: Aborted
 void generateICE(void) {
  ^
0x9957bf crash_signal
../../gcc-5.1.0-source/gcc/toplev.c:383
0xf0c081 build_linearized_memory_access
../../gcc-5.1.0-source/gcc/graphite-interchange.c:128
0xf0c081 pdr_stride_in_loop
../../gcc-5.1.0-source/gcc/graphite-interchange.c:214
0xf0c081 memory_strides_in_loop_1
../../gcc-5.1.0-source/gcc/graphite-interchange.c:300
0xf10f2a lst_interchange_profitable_p
../../gcc-5.1.0-source/gcc/graphite-interchange.c:417
0xf10f2a lst_try_interchange_loops
../../gcc-5.1.0-source/gcc/graphite-interchange.c:554
0xf10f2a lst_interchange_select_inner
../../gcc-5.1.0-source/gcc/graphite-interchange.c:617
0xf13b10 lst_interchange_select_outer
../../gcc-5.1.0-source/gcc/graphite-interchange.c:643
0xf13b5d lst_interchange_select_outer
../../gcc-5.1.0-source/gcc/graphite-interchange.c:653
0xf13bab scop_do_interchange(scop*)
../../gcc-5.1.0-source/gcc/graphite-interchange.c:665
0xe71eaa apply_poly_transforms(scop*)
../../gcc-5.1.0-source/gcc/graphite-poly.c:279
0xe6db18 graphite_transform_loops()
../../gcc-5.1.0-source/gcc/graphite.c:309
0xe6df90 graphite_transforms
../../gcc-5.1.0-source/gcc/graphite.c:338
0xe6df90 execute
../../gcc-5.1.0-source/gcc/graphite.c:419

[Bug preprocessor/66970] New: Add __has_builtin() macro

2015-07-22 Thread gcc at crg4 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66970

Bug ID: 66970
   Summary: Add __has_builtin() macro
   Product: gcc
   Version: 6.0
Status: UNCONFIRMED
  Severity: enhancement
  Priority: P3
 Component: preprocessor
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc at crg4 dot com
  Target Milestone: ---

gcc has a large collection of builtins (intrinsics), as listed at
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

A useful feature would be a __has_builtin() macro, as implemented in clang:
http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros

This would allow feature detection rather than requiring checks against
compiler names and versions.

Support for this enhancement was expressed on the mailing list (Sep 2012)
http://comments.gmane.org/gmane.comp.gcc.help/42610
but it looks like it was never submitted as a bug.