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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> So you say that we fail to optimize
> 
> int foo (unsigned x)
> {
>   unsigned tem = 1/x;
>   if (x == 0)
>     return 5;
>   return tem;
> }
> 
> because we turn 1/x into x == 1?
> 
> A phase ordering issue, obviously.  Relevant in practice?  I'm not sure.

We could surely defer the optimization until GIMPLE and optimize 1/x into ({ if
(!x) __builtin_unreachable (); 1}).  The question is if it is worth it, plus
having conditionals in the IL created by match.pd is difficult.
Perhaps we want some variant way of representing very simple if (!cond)
__builtin_unreachable (); as IFN_RANGE (x_123, ...); where ... would somehow
represent what range x_123 can have.  And a question where to drop those as
well.

Reply via email to