https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112469
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Status|NEW |ASSIGNED --- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- So we value-number vect_prephitmp_11.23_50 = .COND_NEG (_55, vect__29.18_40, { -1, -1, -1, -1, -1, -1, -1, -1 }); as { 4294967295, 4294967294, 4294967293, 4294967292, 4294967291, 4294967290, 4294967289, 4294967288 } where the former is signed int V8SI and the latter unsigned int V8SI. Happens via Value numbering stmt = vect_prephitmp_11.23_50 = .COND_NEG (_55, vect__29.18_40, { -1, -1, -1, -1, -1, -1, -1, -1 }); Applying pattern match.pd:5031, generic-match-1.cc:9440 Match-and-simplified .COND_NEG (_55, vect__29.18_40, { -1, -1, -1, -1, -1, -1, -1, -1 }) to { 4294967295, 4294967294, 4294967293, 4294967292, 4294967291, 4294967290, 4294967289, 4294967288 } where _55 == { -1, -1, -1, -1, -1, -1, -1, -1 } and vect__29.18_40 == { 1, 2, 3, 4, 5, 6, 7, 8 } and we have vector(8) unsigned int vect__29.18; I think the .COND_NEG result has the wrong sign. We fold this from a VEC_COND_EXPR during vectorization: Value numbering stmt = vect_prephitmp_11.23_50 = VEC_COND_EXPR <mask__23.21_44, vect_cst__49, vect__12.20_42>; Matching expression match.pd:2187, gimple-match-4.cc:67 Applying pattern match.pd:5926, gimple-match-3.cc:3142 Setting value number of vect_prephitmp_11.23_50 to vect_prephitmp_11.23_50 (changed) Matching expression match.pd:2187, gimple-match-4.cc:67 Applying pattern match.pd:5926, gimple-match-3.cc:3142 Applying pattern match.pd:8968, gimple-match-3.cc:19689 gimple_simplified to _55 = vect_vec_iv_.17_38 != { 0, 0, 0, 0, 0, 0, 0, 0 }; vect_prephitmp_11.23_50 = .COND_NEG (_55, vect__29.18_40, { -1, -1, -1, -1, -1, -1, -1, -1 }); which is (for uncond_op (UNCOND_UNARY) cond_op (COND_UNARY) .. (simplify (vec_cond @0 @1 (view_convert? (uncond_op@3 @2))) (with { tree op_type = TREE_TYPE (@3); } (if (vectorized_internal_fn_supported_p (as_internal_fn (cond_op), op_type) && is_truth_type_for (op_type, TREE_TYPE (@0))) (cond_op (bit_not @0) @2 @1))))) and because of the view_convert? lacks a view_convert in the result: diff --git a/gcc/match.pd b/gcc/match.pd index f559bfa4f2b..2b5e9554020 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -8965,7 +8965,7 @@ and, (with { tree op_type = TREE_TYPE (@3); } (if (vectorized_internal_fn_supported_p (as_internal_fn (cond_op), op_type) && is_truth_type_for (op_type, TREE_TYPE (@0))) - (cond_op (bit_not @0) @2 @1))))) + (cond_op (bit_not @0) (view_convert @2) @1))))) (for uncond_op (UNCOND_UNARY) cond_op (COND_LEN_UNARY) fixes this.