This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: x86 branches vs conditional moves


On Sat, Jul 8, 2017 at 1:30 AM, Michael Clark wrote:
> Why does gcc branch on _Bool, but emits a conditional move for an integer? can it emit cmovne instead of branching? also curious where one would change this to learn about GCC internals.

The RTL generated for the int and _Bool case is different:

;; Function select_int (select_int, funcdef_no=0, decl_uid=1820,
cgraph_uid=0, symbol_order=0)

    3: NOTE_INSN_BASIC_BLOCK 2
    2: NOTE_INSN_FUNCTION_BEG
    5: flags:CCZ=cmp([`c'],0)
    6: pc={(flags:CCZ==0)?L11:pc}

    7: NOTE_INSN_BASIC_BLOCK 3
    8: r88:SI=[`a']

   11: L11:
   12: NOTE_INSN_BASIC_BLOCK 4
   13: r88:SI=[`b']

   18: L18:
   21: NOTE_INSN_BASIC_BLOCK 5
   19: ax:SI=r88:SI
   20: use ax:SI


;; Function select_bool (select_bool, funcdef_no=1, decl_uid=1822,
cgraph_uid=1, symbol_order=1)

    3: NOTE_INSN_BASIC_BLOCK 2
    2: NOTE_INSN_FUNCTION_BEG
    5: flags:CCZ=cmp([`C'],0)
    6: pc={(flags:CCZ==0)?L13:pc}

    7: NOTE_INSN_BASIC_BLOCK 3
    8: flags:CCZ=cmp([`a'],0)
    9: r90:QI=flags:CCZ!=0

   13: L13:
   14: NOTE_INSN_BASIC_BLOCK 4
   15: flags:CCZ=cmp([`b'],0)
   16: r90:QI=flags:CCZ!=0

   22: L22:
   25: NOTE_INSN_BASIC_BLOCK 5
   23: ax:QI=r90:QI
   24: use ax:QI

As noted earlier, this causes RTL if-conversion to fail.

Somewhat related to PR20070, but even with -fcrossjumping, the test
case fails. (I expected cross-jumping to merge the
"r90:QI=flags:CCZ!=0" insns.)

Ciao!
Steven
<div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br />
<table style="border-top: 1px solid #D3D4DE;">
	<tr>
        <td style="width: 55px; padding-top: 13px;"><a
href="http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail";
target="_blank"><img
src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-green-avg-v1.png";
alt="" width="46" height="29" style="width: 46px; height: 29px;"
/></a></td>
		<td style="width: 470px; padding-top: 12px; color: #41424e;
font-size: 13px; font-family: Arial, Helvetica, sans-serif;
line-height: 18px;">Virus-free. <a
href="http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail";
target="_blank" style="color: #4453ea;">www.avg.com</a>
		</td>
	</tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1"
height="1"></a></div>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]