[Bug tree-optimization/80574] GCC fail to optimize nested ternary

glisse at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Apr 30 14:02:00 GMT 2017


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

--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> ---
With -fdump-tree-original, the signed case looks perfect:

  return MAX_EXPR <MAX_EXPR <MAX_EXPR <MAX_EXPR <MAX_EXPR <a3, a2>, a1>, a3>,
a2>, a1>;

(which reassoc eventually simplifies)
while in the unsigned case, we fail to recognize the innermost max:

  return (unsigned char) MAX_EXPR <MAX_EXPR <MAX_EXPR <MAX_EXPR <a2 > a3 ?
(int) a2 : (int) a3, (int) a1>, (int) a3>, (int) a2>, (int) a1>;

and we also fail during gimple, probably because of the conversions.


More information about the Gcc-bugs mailing list