Re: [OpenACC 1/11] UNIQUE internal function

2015-10-27 Thread Nathan Sidwell
This is the patch that was committed. nathan 2015-10-27 Nathan Sidwell * internal-fn.c (expand_UNIQUE): New. * internal-fn.h (enum ifn_unique_kind): New. * internal-fn.def (IFN_UNIQUE): New. * target-insns.def (unique): Define. * gimple.h (gimple_call_internal_unique_p): New. * gimple.

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-27 Thread Nathan Sidwell
On 10/27/15 01:03, Jakub Jelinek wrote: On Mon, Oct 26, 2015 at 03:32:45PM -0700, Nathan Sidwell wrote: to break out the else part into a separate function. That's fine -- it'll copy the whole CFG of interest. The question is if some UNIQUE call could be ever considered as part of the chea

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-27 Thread Jakub Jelinek
On Tue, Oct 27, 2015 at 07:03:40AM -0700, Nathan Sidwell wrote: > On 10/27/15 06:45, Richard Biener wrote: > >On Tue, Oct 27, 2015 at 9:03 AM, Jakub Jelinek wrote: > > >>Ok for me, but please wait for Richi's ack too. > > > >+ /* An IFN_UNIQUE call must be duplicated as part of its group, >

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-27 Thread Nathan Sidwell
On 10/27/15 06:45, Richard Biener wrote: On Tue, Oct 27, 2015 at 9:03 AM, Jakub Jelinek wrote: Ok for me, but please wait for Richi's ack too. + /* An IFN_UNIQUE call must be duplicated as part of its group, +or not at all. */ + if (is_gimple_call (g) && gimple_call_inter

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-27 Thread Richard Biener
On Tue, Oct 27, 2015 at 9:03 AM, Jakub Jelinek wrote: > On Mon, Oct 26, 2015 at 03:32:45PM -0700, Nathan Sidwell wrote: >> Richard, Jakub, >> this updates patch 1 to use the target-insns.def mechanism of detecting >> conditionally-implemented instructions. Otherwise it's the same as >> yesterday'

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-27 Thread Jakub Jelinek
On Mon, Oct 26, 2015 at 03:32:45PM -0700, Nathan Sidwell wrote: > Richard, Jakub, > this updates patch 1 to use the target-insns.def mechanism of detecting > conditionally-implemented instructions. Otherwise it's the same as > yesterday's patch. To recap: > > 1) Moved the subcodes to an enumerat

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-26 Thread Nathan Sidwell
Richard, Jakub, this updates patch 1 to use the target-insns.def mechanism of detecting conditionally-implemented instructions. Otherwise it's the same as yesterday's patch. To recap: 1) Moved the subcodes to an enumeration in internal-fn.h 2) Remove ECF_LEAF 3) Added check in initialize_c

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-25 Thread Nathan Sidwell
Richard, Jakub, here is an updated patch. Changes from previous version 1) Moved the subcodes to an enumeration in internal-fn.h 2) Remove ECF_LEAF 3) Added check in initialize_ctrl_altering 4) tracer code now (continues) to only look in last stmt of block I looked at fnsplit and do not beli

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-23 Thread Nathan Sidwell
On 10/23/15 09:16, Jakub Jelinek wrote: On Fri, Oct 23, 2015 at 09:13:43AM -0400, Nathan Sidwell wrote: You're correct that the SESE region could be split across a function boundary in the manner you describe, but the complexity of dealing with that in the backend's partitioning code would be h

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-23 Thread Nathan Sidwell
On 10/23/15 09:03, Jakub Jelinek wrote: On Fri, Oct 23, 2015 at 08:57:17AM -0400, Nathan Sidwell wrote: If this is during the omplower pass, then it is before cfg pass and therefore all you need is tweak the gimple_call_initialize_ctrl_altering function and the cfg pass will DTRT. ok, thanks

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-23 Thread Jakub Jelinek
On Fri, Oct 23, 2015 at 09:13:43AM -0400, Nathan Sidwell wrote: > You're correct that the SESE region could be split across a function > boundary in the manner you describe, but the complexity of dealing with > that in the backend's partitioning code would be high. Let's not try and > enable that

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-23 Thread Nathan Sidwell
On 10/23/15 09:03, Richard Biener wrote: It's a hack. I don't like hacks. One person's hack can be another person's pragmatism :) I think the requirement "don't duplicate me" but inlining is ok is somewhat broken. The requirement is that the SESE region formed by the markers remains as a

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-23 Thread Jakub Jelinek
On Fri, Oct 23, 2015 at 08:57:17AM -0400, Nathan Sidwell wrote: > >If you want to force end of a BB after the IFN_UNIQUE call, then you can just > >gimple_call_set_ctrl_altering (gcall, true); > >on it, and probably tweak gimple_call_initialize_ctrl_altering > >so that it does that by default. Plu

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-23 Thread Richard Biener
On Fri, Oct 23, 2015 at 2:57 PM, Nathan Sidwell wrote: > On 10/23/15 04:25, Jakub Jelinek wrote: >> >> On Thu, Oct 22, 2015 at 02:06:54PM -0400, Nathan Sidwell wrote: >>> >>> On 10/22/15 10:26, Richard Biener wrote: On Thu, Oct 22, 2015 at 4:01 PM, Nathan Sidwell wrote: > > On 1

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-23 Thread Nathan Sidwell
On 10/23/15 04:25, Jakub Jelinek wrote: On Thu, Oct 22, 2015 at 02:06:54PM -0400, Nathan Sidwell wrote: On 10/22/15 10:26, Richard Biener wrote: On Thu, Oct 22, 2015 at 4:01 PM, Nathan Sidwell wrote: On 10/22/15 04:07, Richard Biener wrote: Yeah, please make them either end or start a BB so

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-23 Thread Richard Biener
On Thu, Oct 22, 2015 at 8:06 PM, Nathan Sidwell wrote: > On 10/22/15 10:26, Richard Biener wrote: >> >> On Thu, Oct 22, 2015 at 4:01 PM, Nathan Sidwell wrote: >>> >>> On 10/22/15 04:07, Richard Biener wrote: >>> Yeah, please make them either end or start a BB so we have to check at most

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-23 Thread Jakub Jelinek
On Thu, Oct 22, 2015 at 02:06:54PM -0400, Nathan Sidwell wrote: > On 10/22/15 10:26, Richard Biener wrote: > >On Thu, Oct 22, 2015 at 4:01 PM, Nathan Sidwell wrote: > >>On 10/22/15 04:07, Richard Biener wrote: > >> > >>>Yeah, please make them either end or start a BB so we have to check > >>>at mo

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-23 Thread Jakub Jelinek
On Thu, Oct 22, 2015 at 04:17:32PM -0400, Nathan Sidwell wrote: > On 10/22/15 04:04, Jakub Jelinek wrote: > > >>+ /* Ignore blocks containing non-clonable function calls. */ > >>+ for (gsi = gsi_start_bb (CONST_CAST_BB (bb)); > >>+ !gsi_end_p (gsi); gsi_next (&gsi)) > >>+{ > >>+

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Nathan Sidwell
On 10/22/15 04:04, Jakub Jelinek wrote: + /* Ignore blocks containing non-clonable function calls. */ + for (gsi = gsi_start_bb (CONST_CAST_BB (bb)); + !gsi_end_p (gsi); gsi_next (&gsi)) +{ + g = gsi_stmt (gsi); + + if (is_gimple_call (g) && gimple_call_internal_p (g) +

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Nathan Sidwell
On 10/22/15 10:26, Richard Biener wrote: On Thu, Oct 22, 2015 at 4:01 PM, Nathan Sidwell wrote: On 10/22/15 04:07, Richard Biener wrote: Yeah, please make them either end or start a BB so we have to check at most a single stmt. ECF_RETURNS_TWICE should achieve that, it also makes it a code m

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Nathan Sidwell
On 10/22/15 04:07, Richard Biener wrote: Yeah, please make them either end or start a BB so we have to check at most a single stmt. ECF_RETURNS_TWICE should achieve that, it also makes it a code motion barrier. I'm having a hard time making UNIQUE the end of a BB. I'm emitting code to a gim

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Nathan Sidwell
On 10/22/15 10:30, Richard Biener wrote: On Thu, Oct 22, 2015 at 3:24 PM, Nathan Sidwell wrote: Essentially, yes. a set of IFN_UNIQUE form a group which must not be separated from each other. The set is discovered implicitly by following the CFG (though I suppose we could add an identifyin

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Nathan Sidwell
On 10/22/15 10:26, Richard Biener wrote: On Thu, Oct 22, 2015 at 4:01 PM, Nathan Sidwell wrote: RETURNS_TWICE will make the invariant motion stop at UNIQUE (HEAD), but it would have done that anyway. It will also be a CSE barrier, thus tem = global; UNIQUE(HEAD) tem2 = global; will not CSE

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Richard Biener
On Thu, Oct 22, 2015 at 3:24 PM, Nathan Sidwell wrote: > On 10/22/15 09:17, Jakub Jelinek wrote: >> >> On Thu, Oct 22, 2015 at 09:08:30AM -0400, Nathan Sidwell wrote: > > >> I agree with Richard that it would be better to write more about what kind >> of IL changes are acceptable with IFN_UNIQUE i

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Richard Biener
On Thu, Oct 22, 2015 at 4:01 PM, Nathan Sidwell wrote: > On 10/22/15 04:07, Richard Biener wrote: > >> Yeah, please make them either end or start a BB so we have to check >> at most a single stmt. ECF_RETURNS_TWICE should achieve that, >> it also makes it a code motion barrier. > > > Just so I'm

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Nathan Sidwell
On 10/22/15 04:07, Richard Biener wrote: Yeah, please make them either end or start a BB so we have to check at most a single stmt. ECF_RETURNS_TWICE should achieve that, it also makes it a code motion barrier. Just so I'm clear, you're not saying that RETURNS_TWICE will stop the call being

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Nathan Sidwell
On 10/22/15 09:17, Jakub Jelinek wrote: On Thu, Oct 22, 2015 at 09:08:30AM -0400, Nathan Sidwell wrote: I agree with Richard that it would be better to write more about what kind of IL changes are acceptable with IFN_UNIQUE in the IL and what are not. E.g. is inlining ok (I'd hope yes)? Is fu

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Jakub Jelinek
On Thu, Oct 22, 2015 at 09:08:30AM -0400, Nathan Sidwell wrote: > On 10/22/15 07:10, Julian Brown wrote: > >On Thu, 22 Oct 2015 10:05:30 +0200 > >Richard Biener wrote: > > >>So you'd need to be more precise as to what properties you are trying > >>to preserve by placing a single stmt somewhere. >

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Nathan Sidwell
On 10/22/15 07:10, Julian Brown wrote: On Thu, 22 Oct 2015 10:05:30 +0200 Richard Biener wrote: So you'd need to be more precise as to what properties you are trying to preserve by placing a single stmt somewhere. FWIW an earlier, abandoned attempt at solving the same problem was discussed

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Nathan Sidwell
On 10/22/15 04:07, Richard Biener wrote: On Thu, Oct 22, 2015 at 10:04 AM, Jakub Jelinek wrote: Do you have to scan the whole bb? E.g. don't or should not those unique IFNs force end of bb? Yeah, please make them either end or start a BB so we have to check at most a single stmt. ECF_RETU

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Julian Brown
On Thu, 22 Oct 2015 10:05:30 +0200 Richard Biener wrote: > On Thu, Oct 22, 2015 at 9:59 AM, Jakub Jelinek > wrote: > > On Thu, Oct 22, 2015 at 09:49:29AM +0200, Richard Biener wrote: > >> >> Jakub, IYR I originally had IFN_FORK and IFN_JOIN as such > >> >> distinct internal fns. This replaces

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Richard Biener
On Thu, Oct 22, 2015 at 10:04 AM, Jakub Jelinek wrote: > On Wed, Oct 21, 2015 at 03:00:47PM -0400, Nathan Sidwell wrote: >> To distinguish different uses of the UNIQUE function, I use the first >> argument, which is expected to be an INTEGER_CST. I figured this better >> than using multiple new i

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Richard Biener
On Thu, Oct 22, 2015 at 9:59 AM, Jakub Jelinek wrote: > On Thu, Oct 22, 2015 at 09:49:29AM +0200, Richard Biener wrote: >> >> Jakub, IYR I originally had IFN_FORK and IFN_JOIN as such distinct >> >> internal >> >> fns. This replaces that scheme. >> >> >> >> ok? >> > >> > Hmm, I'd just have used

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Jakub Jelinek
On Wed, Oct 21, 2015 at 03:00:47PM -0400, Nathan Sidwell wrote: > To distinguish different uses of the UNIQUE function, I use the first > argument, which is expected to be an INTEGER_CST. I figured this better > than using multiple new internal fns, all with the unique property, as the > latter wo

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Jakub Jelinek
On Thu, Oct 22, 2015 at 09:49:29AM +0200, Richard Biener wrote: > >> Jakub, IYR I originally had IFN_FORK and IFN_JOIN as such distinct internal > >> fns. This replaces that scheme. > >> > >> ok? > > > > Hmm, I'd just have used gimple_has_volatile_ops on the call? That > > should have the > > des

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Richard Biener
On Thu, Oct 22, 2015 at 9:48 AM, Richard Biener wrote: > On Wed, Oct 21, 2015 at 9:00 PM, Nathan Sidwell wrote: >> This patch implements a new internal function that has a 'uniqueness' >> property. Jump-threading cannot clone it and tail-merging cannot combine >> multiple instances. >> >> The u

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-22 Thread Richard Biener
On Wed, Oct 21, 2015 at 9:00 PM, Nathan Sidwell wrote: > This patch implements a new internal function that has a 'uniqueness' > property. Jump-threading cannot clone it and tail-merging cannot combine > multiple instances. > > The uniqueness is implemented by a new gimple fn, > gimple_call_inte

Re: [OpenACC 1/11] UNIQUE internal function

2015-10-21 Thread Nathan Sidwell
This patch implements a new internal function that has a 'uniqueness' property. Jump-threading cannot clone it and tail-merging cannot combine multiple instances. The uniqueness is implemented by a new gimple fn, gimple_call_internal_unique_p. Routines that check for identical or cloneable