Bug 98048 - [11 Regression] ICE in build_vector_from_val, at tree.c:1985 by r11-5429
Summary: [11 Regression] ICE in build_vector_from_val, at tree.c:1985 by r11-5429
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 11.0
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: yarpgen
  Show dependency treegraph
 
Reported: 2020-11-29 01:44 UTC by Vsevolod Livinskii
Modified: 2021-11-01 23:07 UTC (History)
6 users (show)

See Also:
Host:
Target: x86-64
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-11-29 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vsevolod Livinskii 2020-11-29 01:44:43 UTC
Reproducer:
extern short var_0;
extern int var_3;
extern int arr_277[];
int a(int b, int c) { return b < c ? b : c; }
int e;
void test() {
  e = var_0;
  for (int d = 0; d < 9; d++)
    if (var_3)
      arr_277[d] = a(var_0, -var_0);
}

Error:
>$ g++ -c -O3 func.cpp
during GIMPLE pass: veclower2
func.cpp: In function ‘void test()’:
func.cpp:6:6: internal compiler error: in build_vector_from_val, at tree.c:1985
    6 | void test() {
      |      ^~~~
0x88bffd build_vector_from_val(tree_node*, tree_node*)
	/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree.c:1985
0x13a22cd expand_vector_operations_1
	/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree-vect-generic.c:2095
0x13a22cd expand_vector_operations
	/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree-vect-generic.c:2291
0x13a22cd execute
	/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree-vect-generic.c:2337
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

gcc version 11.0.0 20201126 (beb9afcaf1466996a301c778596c5df209e7913c)
Comment 1 H.J. Lu 2020-11-29 03:51:02 UTC
It is caused by r11-5429
Comment 2 Uroš Bizjak 2020-11-29 18:28:36 UTC
The patch exposed a bug in generic vector handling code.

We have:

      if (op >= FIRST_NORM_OPTAB && op <= LAST_NORM_OPTAB
	  && optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing)

where abs_optab in E_HImode enables this condition.

There is nothing wrong with the patch itself.
Comment 3 Richard Biener 2020-11-30 08:10:12 UTC
I will have a look.
Comment 4 GCC Commits 2020-11-30 12:28:13 UTC
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:4bcded23eb87c55a1a3fcd23d5629a0c35aee4ba

commit r11-5539-g4bcded23eb87c55a1a3fcd23d5629a0c35aee4ba
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Nov 30 10:41:36 2020 +0100

    tree-optimization/98048 - fix vector lowering of ABSU_EXPR
    
    This makes sure to use the correct type for the LHS of the scalar
    replacement statement.
    
    20220-11-30  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/98048
            * tree-vect-generic.c (expand_vector_operations_1): Use the
            correct type for the scalar LHS replacement.
    
            * gcc.dg/vect/pr98048.c: New testcase.
Comment 5 Richard Biener 2020-11-30 12:43:14 UTC
Fixed.