https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128489
Bug ID: 128489
Summary: [17 Regression] match pattern introduces CONVERT_EXPR
instead of VCE for vectors
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: pinskia at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Created attachment 66101
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=66101&action=edit
testcase
This match pattern:
```
/* x != CST1 ? x + CST2 : CST3 -> x + CST2 when CST1 + CST2 == CST3.
This handles both scalars and uniform vectors. */
(for cnd (cond vec_cond)
(simplify
(cnd (ne @0 uniform_integer_cst_p@1)
(plus@2 @0 uniform_integer_cst_p@3)
uniform_integer_cst_p@4)
(with {
tree cst1 = uniform_integer_cst_p (@1);
tree cst2 = uniform_integer_cst_p (@3);
tree cst3 = uniform_integer_cst_p (@4);
wi::overflow_type ovf;
}
(if (wi::add (wi::to_wide (cst1), wi::to_wide (cst2),
TYPE_SIGN (TREE_TYPE (cst1)), &ovf) == wi::to_wide (cst3))
(if (!ovf || TYPE_OVERFLOW_WRAPS (TREE_TYPE (cst1)))
@2
(with {
tree utype = unsigned_type_for (type);
}
(convert (plus (convert:utype @0) (convert:utype @3)))))))))
```
Should be using view_convert instead of convert. Most places expect VCE rather
than convert (which seemily acts like a copy for big vectors)
Testcase attached.