On Sun, Jun 9, 2019 at 11:15 PM Alex Hill via gcc-help <gcc-help@xxxxxxxxxxx> wrote: > I found some decision, i used flags -fexceptions -fnon-call-exceptions and it emits max insn, now i try to understand why this happens. > Here is the max it emits: > (define_insn "smax<GPR:mode>3" > [(set (match_operand:GPR 0 "register_operand" "=r") > (smax:GPR (match_operand:GPR 1 "register_operand" " r") > (match_operand:GPR 2 "register_operand" " r")))] > "" > "max\t%0,%1,%2" > [(set_attr "type" "move") > (set_attr "mode" "<MODE>")]) There is some code in noce_try_minmax in ifcvt.c that will try to recognize an if statement in RTL that performs min/max and try to convert it to a direct min/max operation. However, in general, you are more likely to get a min/max operation if you recognize it when parsing, and then carry it all of the way through the optimizer. To make that work, you need min/max named patterns, that emit min/max operations in RTL. Like what you have immediately above. If trying to understand how this works, look at the debugging dumps you can get with -fdump-tree-all and -fdump-rtl-all when compiling a trivial testcase. And maybe compare with another CPU target that already has working min/max support. Jim