[Bug tree-optimization/96707] Failure to optimize right shift+unsigned compare of two variables optimally

amacleod at redhat dot com gcc-bugzilla@gcc.gnu.org
Wed Jan 12 02:00:27 GMT 2022


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

--- Comment #4 from Andrew Macleod <amacleod at redhat dot com> ---
The IL generated is:

  _1 = x_2(D) >> y_3(D);
  _4 = _1 <= x_2(D);
  return _4;

All that should be needed is for the right shift operator in range-ops to
implement lhs_op1_relation() to indicate that if the range of op2 is >=0, then 
return LE_EXPR.   

this will automatically register  the relation _1 <= x_2 at the def point for
_1, and then _4 should simply fold away as true.


More information about the Gcc-bugs mailing list