# Why isn't minmax branchless?

**URL:** <https://discourse.julialang.org/t/why-isnt-minmax-branchless/64854>\
**Category:** Internals & Design\
**Created:** [July 18, 2021, 11:27am UTC](https://discourse.julialang.org/t/why-isnt-minmax-branchless/64854 "2021-07-18T11:27:57Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [July 19, 2021, 4:33pm UTC](https://discourse.julialang.org/t/why-isnt-minmax-branchless/64854/21 "2021-07-19T16:33:43Z")

</div>

> [@anon56330260](#):
>
> Instead, I think we should just define `Base.ifelse` only on a constraint set of types

That would be a breaking change.

---

<div class="post-metadata">

**Author:** ![Luapulu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luapulu/32/17669_2.png) [@Luapulu](https://discourse.julialang.org/u/Luapulu)\
**Post date:** [July 20, 2021, 4:48am UTC](https://discourse.julialang.org/t/why-isnt-minmax-branchless/64854/22 "2021-07-20T04:48:35Z")

</div>

@anon56330260’s suggestion could still be implemented in a more soft sense by updating the docs to recommend only using `ifelse` for that certain subset of types. We could also have a little section on `ifelse` in the performance section of the manual.

---

<div class="post-metadata">

**Author:** ![Luapulu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luapulu/32/17669_2.png) [@Luapulu](https://discourse.julialang.org/u/Luapulu)\
**Post date:** [July 20, 2021, 5:59am UTC](https://discourse.julialang.org/t/why-isnt-minmax-branchless/64854/23 "2021-07-20T05:59:19Z")

</div>

> [@anon56330260](#):
>
> It’s not generic by design (it lowers to `select` and not all the values can be the operands of select).

Why do you say that? If you made `ifelse` generic, couldn’t you add methods to deal with more complex types and lower them to a series of select statements more intelligently?

And to ask a potentially dumb question: why can’t we make Julia’s frontend compiler aware of `ifelse`? What does making the compiler ‘aware’ mean?

[Previous page](https://discourse.julialang.org/t/why-isnt-minmax-branchless/64854.md?page=1)
