From: Tom de Vries Date: Mon, 17 Jul 2017 07:49:22 +0000 (+0000) Subject: Insert diverging jump alap in nvptx_single X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ed9091b270721c399112c74eb15b7fc27ef127db;p=gcc.git Insert diverging jump alap in nvptx_single 2017-07-17 Tom de Vries PR target/81069 * config/nvptx/nvptx.c (nvptx_single): Insert diverging branch as late as possible. From-SVN: r250256 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 672b21224c7..67b7ff12d95 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-07-17 Tom de Vries + + PR target/81069 + * config/nvptx/nvptx.c (nvptx_single): Insert diverging branch as late + as possible. + 2017-07-17 Sebastian Huber * gcc/config/sparc/rtemself.h (TARGET_OS_CPP_BUILTINS): Add diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index c8847a5dbba..78ce1213497 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -3886,9 +3886,25 @@ nvptx_single (unsigned mask, basic_block from, basic_block to) rtx_insn *tail = BB_END (to); unsigned skip_mask = mask; - /* Find first insn of from block */ - while (head != BB_END (from) && !INSN_P (head)) - head = NEXT_INSN (head); + while (true) + { + /* Find first insn of from block. */ + while (head != BB_END (from) && !INSN_P (head)) + head = NEXT_INSN (head); + + if (from == to) + break; + + if (!(JUMP_P (head) && single_succ_p (from))) + break; + + basic_block jump_target = single_succ (from); + if (!single_pred_p (jump_target)) + break; + + from = jump_target; + head = BB_HEAD (from); + } /* Find last insn of to block */ rtx_insn *limit = from == to ? head : BB_HEAD (to);