Hello, Is there a way to activate control speculation of loads in GCC, starting with the ia64 target? For a loop as simple as on GCC 7.5, I could not get any:
double list_sum(list_cell list) { double result = 0.0; while (list->next) { list = list->next; result += list->payload; if (!list->next) break; list = list->next; result += list->payload; } return result; } Kalray has developed a 64-bit Fisher-style VLIW architecture ('KVX') for use in a manycore processor it produces. These VLIW cores run Linux, and Kalray develops GCC and LLVM code generators for them (see kvx compilers on https://godbolt.org/z/ZJGzje ). VLIW performance on non-numerical code is critically dependent on the control speculation of loads. Being a Fischer-style VLIW, the kvx architecture has dismissable loads instead of control speculative loads, so there is no need to create speculation check with recovery code. I first tried in prepass scheduling with SCHED_RGN, hoping from various comments in the source file that it could move loads across blocks (sched-rgn.c:26 The first run performs interblock scheduling, moving insns between different blocks in the same "region"). SCHED_EBB is not available in prepass and SEL_SCHED does not work with control speculation: not only from experience with the kvx retargeting where it breaks dataflow invariants, but also as hinted by logic in ia64.c:ia64_set_sched_flags(). My question is whether GCC can or cannot do any control speculation of loads during prepass scheduling. From what I observed, enabling control speculation in region scheduling only enables the load instructions to get ready earlier in their home basic block, not being scheduled in a dominator basic block like expected to happen for improving performance in the above example. Thanks for any advice. Benoît Dinechin
list_sum-ia64.s
Description: Binary data
list_sum-kvx.s
Description: Binary data