https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64015
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Zhenqiang Chen from comment #2) > 2) How to justify it is valueable (the overhead of ccmp is OK) when > generating ccmp? If we ignore the case for swapping. Try this one: int test (int a, int b) { return (a > 252) && b > 252; } With my patch to do the forcing: test: cmp w0, 252 mov w0, 252 ccmp w1, w0, 4, gt cset w0, gt ret Without: test: cmp w0, 252 cset w2, gt cmp w1, 252 cset w0, gt and w0, w2, w0 ret Or better yet take: int test (int a, int b) { return (a > 321223) && b > 321224; } Without: test: mov w3, 59079 mov w2, 59080 movk w3, 0x4, lsl 16 movk w2, 0x4, lsl 16 cmp w0, w3 cset w3, gt cmp w1, w2 cset w0, gt and w0, w3, w0 ret With forcing: test: mov w3, 59079 mov w2, 59080 movk w3, 0x4, lsl 16 movk w2, 0x4, lsl 16 cmp w0, w3 ccmp w1, w2, 4, gt cset w0, gt ret --- CUT --- Also take: int test (int a, int b) { return (a > 33) && b > 33; } Without: test: cmp w0, 33 cset w2, gt cmp w1, 33 cset w0, gt and w0, w2, w0 ret With forcing: test: cmp w0, 33 mov w0, 33 ccmp w1, w0, 4, gt cset w0, gt ret See how with forcing is always the same size or smaller?