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)
It is caused by r11-5429
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.
I will have a look.
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.
Fixed.