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.
--- /dev/null
+/* { 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);
+}
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,