[Bug tree-optimization/90913] [10 Regression] ICE in maybe_gen_insn, at optabs.c:7341 since r272239

2019-06-21 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90913

Richard Biener  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #10 from Richard Biener  ---
Should be fixed now.

[Bug tree-optimization/90913] [10 Regression] ICE in maybe_gen_insn, at optabs.c:7341 since r272239

2019-06-21 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90913

--- Comment #9 from Richard Biener  ---
Author: rguenth
Date: Fri Jun 21 11:10:39 2019
New Revision: 272545

URL: https://gcc.gnu.org/viewcvs?rev=272545&root=gcc&view=rev
Log:
2019-06-21  Richard Biener  

PR tree-optimization/90913
* tree-vect-loop-manip.c (vect_loop_versioning): Do not re-use
the scalar variant of if-conversion versioning.

* gfortran.dg/vect/pr90913.f90: New testcase.

Added:
trunk/gcc/testsuite/gfortran.dg/vect/pr90913.f90
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-vect-loop-manip.c

[Bug tree-optimization/90913] [10 Regression] ICE in maybe_gen_insn, at optabs.c:7341 since r272239

2019-06-20 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90913

--- Comment #8 from Martin Liška  ---
One more test-case:

$ gcc /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/pr70177.c -fwrapv
-mavx5124fmaps -O3
during RTL pass: expand
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/pr70177.c: In function ‘foo’:
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/pr70177.c:8:1: internal
compiler error: in maybe_gen_insn, at optabs.c:7379
8 | foo (int i, int j)
  | ^~~
0x693c2c maybe_gen_insn(insn_code, unsigned int, expand_operand*)
/home/marxin/Programming/gcc/gcc/optabs.c:7379
0xc80838 maybe_expand_insn(insn_code, unsigned int, expand_operand*)
/home/marxin/Programming/gcc/gcc/optabs.c:7423
0xc80838 expand_insn(insn_code, unsigned int, expand_operand*)
/home/marxin/Programming/gcc/gcc/optabs.c:7454
0xb5d98b expand_mask_store_optab_fn
/home/marxin/Programming/gcc/gcc/internal-fn.c:2536
0x9345e7 expand_call_stmt
/home/marxin/Programming/gcc/gcc/cfgexpand.c:2638
0x9345e7 expand_gimple_stmt_1
/home/marxin/Programming/gcc/gcc/cfgexpand.c:3709
0x9345e7 expand_gimple_stmt
/home/marxin/Programming/gcc/gcc/cfgexpand.c:3868
0x939df1 expand_gimple_basic_block
/home/marxin/Programming/gcc/gcc/cfgexpand.c:5908
0x93bb57 execute
/home/marxin/Programming/gcc/gcc/cfgexpand.c:6531

[Bug tree-optimization/90913] [10 Regression] ICE in maybe_gen_insn, at optabs.c:7341 since r272239

2019-06-20 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90913

Richard Biener  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |rguenth at gcc dot 
gnu.org

--- Comment #7 from Richard Biener  ---
Aww.  OK, so this is when we vectorize the inner loop of an if-converted
outer-loop, then the outer loop LOOP_VECTORIZED condition replaced with the
versioning condition dispatches to the variant supposed to be _scalar_ and the
fallback
is the if-converted nested copy designed for vectorization.

So re-using the if-conversion copy is only possible when loop_to_version is
the inner loop or we are vectorizing the outer loop (I think we never do
versioning on outer loops currently though).

Testing patch.

[Bug tree-optimization/90913] [10 Regression] ICE in maybe_gen_insn, at optabs.c:7341 since r272239

2019-06-20 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90913

--- Comment #6 from Jakub Jelinek  ---
The ICE is because .MASK_LOAD/.MASK_STORE calls are supported just for vectors.
The way it is done is that during ifcvt those internal calls are added to the
.LOOP_VECTORIZED guarded loops, and either we successfully vectorize those,
then the .MASK_LOAD/.MASK_STORE ifn calls are replaced with their vectorized
versions and all the checking is performed, or we should DCE that loop.
The r272239 change which I haven't really understood breaks this on this
testcase, we end up with
  _116 = .LOOP_VECTORIZED (1, 4);
  if (_116 != 0)
goto ; [100.00%]
  else
goto ; [100.00%]
that guards these scalar .MASK_STORE calls being replaced with
  _116 = 0;
  if (_190 != 0)
goto ; [100.00%]
  else
goto ; [100.00%]
that is just wrong, we can't and shouldn't reuse the for vectorization only
loop if we don't vectorize it.  Both because of these .MASK* calls, but also
because e.g. there are COND_EXPRs all around in that which often isn't
beneficial in scalar loops, etc.

[Bug tree-optimization/90913] [10 Regression] ICE in maybe_gen_insn, at optabs.c:7341 since r272239

2019-06-20 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90913

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek  ---
Somewhat reduced:
! PR tree-optimization/90913
! { dg-do compile }
! { dg-options "-O3 -ffast-math" }
! { dg-additional-options "-mavx -mveclibabi=svml" { target i?86-*-* x86_64-*-*
} }
subroutine foo (a, b, c, d, e, f, g, h, k, l)
  implicit none
  integer :: d, e, f, g, i, j
  real :: a, b(5,6), c(6), h(6,10,5), k(5,10,2), l(10,5), m, n, o
  do i=1,5
do j=1,6
  m=l(f,g)*log(c(j))
  if (m<2) then
if (m<-2) then
  h(j,f,g)=n
else
  h(j,f,g)=o
endif
  endif
  b(i,j)=a+k(i,d,e)+k(i,1,e)**h(j,f,g)
enddo
  enddo
  write(*,'()') 
end

[Bug tree-optimization/90913] [10 Regression] ICE in maybe_gen_insn, at optabs.c:7341 since r272239

2019-06-18 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90913

--- Comment #4 from Richard Biener  ---
Somehow we end up with

(gdb) p debug_tree (maskt)
 
unit-size 
align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x76c52b28 precision:1 min  max >
visited
def_stmt _157 = _155 & _21;
version:157>

this must be a latent issue.

[Bug tree-optimization/90913] [10 Regression] ICE in maybe_gen_insn, at optabs.c:7341 since r272239

2019-06-18 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90913

--- Comment #3 from Richard Biener  ---
Reproduced with -Ofast -march=znver1 -mveclibabi=svml

[Bug tree-optimization/90913] [10 Regression] ICE in maybe_gen_insn, at optabs.c:7341 since r272239

2019-06-18 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90913

--- Comment #2 from Martin Liška  ---
Created attachment 46500
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46500&action=edit
optimized dump file

[Bug tree-optimization/90913] [10 Regression] ICE in maybe_gen_insn, at optabs.c:7341 since r272239

2019-06-18 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90913

--- Comment #1 from Martin Liška  ---
$ (gdb) bt
#0  fancy_abort (file=0x18cc0d0 "/home/marxin/Programming/gcc/gcc/optabs.c",
line=7341, function=0x18cc738 "maybe_gen_insn") at
/home/marxin/Programming/gcc/gcc/diagnostic.c:1614
#1  0x00d16618 in maybe_gen_insn (icode=CODE_FOR_nothing, nops=3,
ops=0x7fffd580) at /home/marxin/Programming/gcc/gcc/optabs.c:7341
#2  0x00d16a68 in maybe_expand_insn (icode=CODE_FOR_nothing, nops=3,
ops=0x7fffd580) at /home/marxin/Programming/gcc/gcc/optabs.c:7385
#3  0x00d16afc in expand_insn (icode=CODE_FOR_nothing, nops=3,
ops=0x7fffd580) at /home/marxin/Programming/gcc/gcc/optabs.c:7416
#4  0x00be03e4 in expand_mask_store_optab_fn (stmt=0x7756d7e0,
optab=maskstore_optab) at /home/marxin/Programming/gcc/gcc/internal-fn.c:2536
#5  0x00be3f18 in expand_MASK_STORE (fn=IFN_MASK_STORE,
stmt=0x7756d7e0) at /home/marxin/Programming/gcc/gcc/internal-fn.def:133
#6  0x00be5406 in expand_internal_call (fn=IFN_MASK_STORE,
stmt=0x7756d7e0) at /home/marxin/Programming/gcc/gcc/internal-fn.c:3573
#7  0x00be5431 in expand_internal_call (stmt=0x7756d7e0) at
/home/marxin/Programming/gcc/gcc/internal-fn.c:3581
#8  0x009af7f8 in expand_call_stmt (stmt=0x7756d7e0) at
/home/marxin/Programming/gcc/gcc/cfgexpand.c:2638
#9  expand_gimple_stmt_1 (stmt=) at
/home/marxin/Programming/gcc/gcc/cfgexpand.c:3709
#10 expand_gimple_stmt (stmt=) at
/home/marxin/Programming/gcc/gcc/cfgexpand.c:3868
#11 0x009b5002 in expand_gimple_basic_block (bb=,
disable_tail_calls=) at
/home/marxin/Programming/gcc/gcc/cfgexpand.c:5908
#12 0x009b6d68 in (anonymous namespace)::pass_expand::execute
(this=, fun=0x77903000) at
/home/marxin/Programming/gcc/gcc/cfgexpand.c:6531
#13 0x00d35cfa in execute_one_pass (pass=) at /home/marxin/Programming/gcc/gcc/passes.c:2473
#14 0x00d36450 in execute_pass_list_1 (pass=) at /home/marxin/Programming/gcc/gcc/passes.c:2559
#15 0x00d36489 in execute_pass_list (fn=0x77903000, pass=) at /home/marxin/Programming/gcc/gcc/passes.c:2570
#16 0x009ec780 in cgraph_node::expand (this=) at
/home/marxin/Programming/gcc/gcc/context.h:48
#17 0x009ed71c in expand_all_functions () at
/home/marxin/Programming/gcc/gcc/cgraphunit.c:2332
#18 symbol_table::compile (this=0x77732100) at
/home/marxin/Programming/gcc/gcc/cgraphunit.c:2683
#19 0x009eff1d in symbol_table::compile (this=0x77732100) at
/home/marxin/Programming/gcc/gcc/cgraphunit.c:2861
#20 symbol_table::finalize_compilation_unit (this=0x77732100) at
/home/marxin/Programming/gcc/gcc/cgraphunit.c:2861
#21 0x00e09e3d in compile_file () at
/home/marxin/Programming/gcc/gcc/toplev.c:481
#22 0x007f1938 in do_compile () at
/home/marxin/Programming/gcc/gcc/toplev.c:2209
#23 toplev::main (this=this@entry=0x7fffdabe, argc=,
argc@entry=14, argv=, argv@entry=0x7fffdbb8) at
/home/marxin/Programming/gcc/gcc/toplev.c:2344
#24 0x007f544f in main (argc=14, argv=0x7fffdbb8) at
/home/marxin/Programming/gcc/gcc/main.c:39

$ (gdb) frame 4
#4  0x00be03e4 in expand_mask_store_optab_fn (stmt=0x7756d7e0,
optab=maskstore_optab) at /home/marxin/Programming/gcc/gcc/internal-fn.c:2536
2536  expand_insn (icode, 3, ops);
(gdb) p stmt
$3 = (gcall *) 0x7756d7e0
(gdb) pgg
warning: Expression is not an assignment (and might have no effect)
# .MEM_188 = VDEF <_173>
.MASK_STORE (_485, 32B, _157, cm3_125(D));

$ (gdb) p mem
$4 = (rtx) 0x776e38e8
(gdb) pr
warning: Expression is not an assignment (and might have no effect)
(mem:SF (reg/f:DI 316 [ _484 ]) [1 MEM[base: _484, offset: 0B]+0 S4 A32])
(gdb) p mask
$5 = (rtx) 0x776e3af8
(gdb) pr
warning: Expression is not an assignment (and might have no effect)
(subreg:QI (reg:HI 489) 0)
(gdb) p reg
$6 = (rtx) 0x776c9c18
(gdb) pr
warning: Expression is not an assignment (and might have no effect)
(reg/v:SF 151 [ cm3 ])
(gdb) p type
$7 = 
(gdb) p maskt
$8 =