Comment 5 for bug 917967

Revision history for this message
In , Ira Rosen (irar) wrote :

This is actually the same problem as in pr 51301, and the fix of 51301 looks incomplete: we want an over-promoted sequence to end with type demotion operation, so we need to check that properly:

Index: tree-vect-patterns.c
===================================================================
--- tree-vect-patterns.c (revision 182840)
+++ tree-vect-patterns.c (working copy)
@@ -1186,13 +1186,15 @@
     {
       use_lhs = gimple_assign_lhs (use_stmt);
       use_type = TREE_TYPE (use_lhs);
- /* Support only type promotion or signedess change. Check that USE_TYPE
- is not bigger than the original type. */
+ /* Support only type demotion or signedess change. */
       if (!INTEGRAL_TYPE_P (use_type)
- || TYPE_PRECISION (new_type) > TYPE_PRECISION (use_type)
- || TYPE_PRECISION (type) < TYPE_PRECISION (use_type))
+ || TYPE_PRECISION (type) <= TYPE_PRECISION (use_type))
         return NULL;

+ /* Check that NEW_TYPE is not bigger than the conversion result. */
+ if (TYPE_PRECISION (new_type) > TYPE_PRECISION (use_type))
+ return NULL;
+
       if (TYPE_UNSIGNED (new_type) != TYPE_UNSIGNED (use_type)
           || TYPE_PRECISION (new_type) != TYPE_PRECISION (use_type))
         {

I am going to test this patch.