https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101226

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
          Component|d                           |tree-optimization
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-07-16
           Keywords|                            |missed-optimization
                 CC|                            |pinskia at gcc dot gnu.org
           Assignee|ibuclaw at gdcproject dot org      |unassigned at gcc dot 
gnu.org

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
  _2 = (uint) value.1_1;
  _3 = _2 >> 5;
  _4 = (ubyte) _3;

Right this could be optimized at the tree level to be :
  _4 = value.1_1 >> 5;


Something like this for match.pd (note this is not fully correct just close
enough for someone else to start):
(simplify
 (convert (shift (convert@0 @1) INTEGER_CST@2))
 (if (type == TREE_TYPE (@0) && TYPE_SIGN (TREE_TYPE(@0) == TYPE_SIGN (type))
  (if (@2 >= bitsintype(type))
   ({build_zero_cst (type);})
   (shift @1 @2))))

Reply via email to