https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110170
--- Comment #10 from Hongtao.liu <crazylht at gmail dot com> --- There're couple of other issues. 1. rtx_cost for and/ior/xor:SF/DF is not right, it actually generate vector instructions. 2. branch_cost is COSTS_N_INSN(1) instead of BRANCH_COST (). which make noce more conservative to eliminate condition. w/ sse2, backend tries (insn 34 0 36 (set (reg:DF 86 [ _1 ]) (reg:DF 82 [ _1 ])) 151 {*movdf_internal} (nil)) (insn 36 34 37 (set (reg:DF 92) (unspec:DF [ (reg:DF 83 [ _2 ]) (reg:DF 82 [ _1 ]) ] UNSPEC_IEEE_MAX)) -1 (nil)) (insn 37 36 38 (set (reg:DF 93) (lt:DF (reg:DF 82 [ _1 ]) (reg:DF 83 [ _2 ]))) -1 (nil)) (insn 38 37 39 (set (reg:DF 94) (and:DF (reg:DF 86 [ _1 ]) (reg:DF 93))) -1 (nil)) (insn 39 38 40 (set (reg:DF 95) (and:DF (not:DF (reg:DF 93)) (reg:DF 83 [ _2 ]))) -1 (nil)) (insn 40 39 41 (set (reg:DF 83 [ _2 ]) (ior:DF (reg:DF 95) (reg:DF 94))) -1 (nil)) (insn 41 40 0 (set (reg:DF 82 [ _1 ]) (reg:DF 92)) 151 {*movdf_internal} (nil)) which is cost is 28, and original cost is 12 (3 moves + 1 branch).(needs also conside comparison? since it's counted in cmov seq), if use ix86_branch_cost + count comparison cost in the orginal seq, then the cost should be 28 vs 28.) (insn 5 17 6 3 (set (reg:DF 86 [ _1 ]) (reg:DF 82 [ _1 ])) "/export/users/liuhongt/tools-build/build_intel-innersource_pr110170_debug/test.c":5:23 151 {*movdf_internal} (expr_list:REG_DEAD (reg:DF 82 [ _1 ]) (nil))) (insn 6 5 7 3 (set (reg:DF 82 [ _1 ]) (reg:DF 83 [ _2 ])) "/export/users/liuhongt/tools-build/build_intel-innersource_pr110170_debug/test.c":6:15 discrim 1 151 {*movdf_internal} (expr_list:REG_DEAD (reg:DF 83 [ _2 ]) (nil))) (insn 7 6 18 3 (set (reg:DF 83 [ _2 ]) (reg:DF 86 [ _1 ])) "/export/users/liuhongt/tools-build/build_intel-innersource_pr110170_debug/test.c":5:23 discrim 1 151 {*movdf_internal} (expr_list:REG_DEAD (reg:DF 86 [ _1 ]) (nil)))