http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59625
Bug ID: 59625 Summary: asm goto and TARGET_FOUR_JUMP_LIMIT Product: gcc Version: 4.8.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org CC: hubicka at gcc dot gnu.org, rth at gcc dot gnu.org On the following testcase (with 4.8 with say -O2 -mtune=generic, with 4.9 starting with r203012 with e.g. -O2 -mtune=atom) we generate extra .p2align directives in between the asm goto. #define EFAULT 14 #define put_user_try do {\ __label__ put_user_fail;\ stac();\ barrier(); #define put_user_catch(err)\ clac();\ if (0) {\ put_user_fail:\ clac();\ (err) = -EFAULT;\ }\ } while (0) # define _ASM_EXTABLE_EX(from,to) \ " .pushsection \"__ex_table\",\"a\"\n" \ " .balign 8\n" \ " .long (" #from ") - .\n" \ " .long (" #to ") - . + 0x7ffffff0\n" \ " .popsection\n" #define __put_user_asm_ex(x, addr, itype, rtype, ltype)\ asm goto("1:mov"itype" %"rtype"0,%1\n"\ _ASM_EXTABLE_EX(1b, %l[put_user_fail])\ : : ltype(x), "m" (addr) : : put_user_fail) int main(int argc, char **argv) { int err = 0; put_user_try { __put_user_asm_ex(0, argv[0], "q", "", "er"); __put_user_asm_ex(0, argv[1], "q", "", "er"); __put_user_asm_ex(0, argv[2], "q", "", "er"); __put_user_asm_ex(0, argv[3], "q", "", "er"); __put_user_asm_ex(0, argv[4], "q", "", "er"); } put_user_catch(err); return err; } This is from TARGET_FOUR_JUMP_LIMIT ix86_avoid_jump_mispredicts. Perhaps we shouldn't count asm goto as a jump there (i.e. add "&& asm_noperands (PATTERN (insn)) < 0" next to every JUMP_P (insn) in that routine)? Because while asm goto could contain a jump, it can contain something completely different too (as in this case), not to mention that we have to conservatively count the asm goto as occupying 0 bytes in the cache line.