[Bug target/18154] Inefficient max/min code for PowerPC

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Jan 30 18:57:00 GMT 2016


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

--- Comment #9 from Martin Sebor <msebor at gcc dot gnu.org> ---
I noticed while looking at an unrelated bug that when targeting power7 or
power8 Clang makes use of the isel instruction and emits the following:

min:                                    # @min
        cmpw     3, 4
        isel 3, 3, 4, 0
        blr

Gcc also has the capability of using isel but it's disabled by default even
when targeting power8 and must be explicitly enabled via -misel.  With it, GCC
emits the following branchless code:

min:
        cmpw 7,3,4
        isel 3,3,4,28
        extsw 3,3
        blr

Since the instruction exists for just this purpose (eliminating branches),
would it make sense to enable it by default?  (I suppose one concern with it
might be that it's not being very extensively tested.)


More information about the Gcc-bugs mailing list