int r1(int x, int y)
return y ^ ((x ^ y) & -(x < y));
int r2(int x, int y)
return x ^ ((x ^ y) & -(x < y));
`r1` can be optimized to `min` and `r2` to `max`. This transformation is done by LLVM, but not by GCC.
Comparison here: https://godbolt.org/z/hNhkqM
Seems this is PR92834 just using ^ instead of -.
Created attachment 48475 [details]
The master branch has been updated by Jakub Jelinek <email@example.com>:
Author: Jakub Jelinek <firstname.lastname@example.org>
Date: Fri May 8 10:52:47 2020 +0200
match.pd: A ^ ((A ^ B) & -(C cmp D)) -> (C cmp D) ? B : A simplification [PR94786]
We already have x - ((x - y) & -(z < w)) and
x + ((y - x) & -(z < w)) simplifications, this one adds
x ^ ((x ^ y) & -(z < w)) (not merged using for because of the
:c that can be present on bit_xor and can't on minus).
2020-05-08 Jakub Jelinek <email@example.com>
* match.pd (A ^ ((A ^ B) & -(C cmp D)) -> (C cmp D) ? B : A): New
* gcc.dg/tree-ssa/pr94786.c: New test.