[Bug target/105670] [x86] suboptimal code for branch over two bools

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri May 20 18:04:08 GMT 2022


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-05-20
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Gimple level is good:
  _7 = a_2(D) & b_3(D);
  if (_7 != 0)
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

But at expand it changes the above to:
(insn 11 10 12 (set (reg:CCZ 17 flags)
        (compare:CCZ (reg/v:QI 83 [ a ])
            (const_int 0 [0]))) "/app/example.cpp":2:3 -1
     (nil))

(jump_insn 12 11 13 (set (pc)
        (if_then_else (eq (reg:CCZ 17 flags)
                (const_int 0 [0]))
            (label_ref 0)
            (pc))) "/app/example.cpp":2:3 -1
     (int_list:REG_BR_PROB 268435460 (nil)))

(insn 13 12 14 (set (reg:CCZ 17 flags)
        (compare:CCZ (reg/v:QI 85 [ b ])
            (const_int 0 [0]))) "/app/example.cpp":2:3 -1
     (nil))

(jump_insn 14 13 0 (set (pc)
        (if_then_else (eq (reg:CCZ 17 flags)
                (const_int 0 [0]))
            (label_ref 0)
            (pc))) "/app/example.cpp":2:3 -1
     (int_list:REG_BR_PROB 357913948 (nil)))


I noticed LLVM does the same as GCC here ...
While ICC does the one test.


More information about the Gcc-bugs mailing list