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.
This commit is contained in:
Richard Biener 2020-11-30 10:41:36 +01:00
parent 5877c544c1
commit 4bcded23eb
2 changed files with 15 additions and 1 deletions

View File

@ -0,0 +1,14 @@
/* { dg-do compile } */
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);
}

View File

@ -2089,7 +2089,7 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi,
if (op >= FIRST_NORM_OPTAB && op <= LAST_NORM_OPTAB
&& optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing)
{
tree slhs = make_ssa_name (TREE_TYPE (srhs1));
tree slhs = make_ssa_name (TREE_TYPE (TREE_TYPE (lhs)));
gimple *repl = gimple_build_assign (slhs, code, srhs1, srhs2);
gsi_insert_before (gsi, repl, GSI_SAME_STMT);
gimple_assign_set_rhs_from_tree (gsi,