Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v3]

2024-10-29 Thread Jasmine Karthikeyan
On Mon, 28 Oct 2024 04:55:37 GMT, Quan Anh Mai wrote: >> Ah, I see what you mean now. I think this makes extending IGVN more >> appealing because we could continue to do Ideal on lowered nodes, as you >> mentioned. We could override `PhaseGVN::apply_ideal` to return `nullptr` >> when processin

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v3]

2024-10-29 Thread Jasmine Karthikeyan
> Hi all, > This patch adds a new pass to consolidate lowering of complex > backend-specific code patterns, such as `MacroLogicV` and the optimization > proposed by #21244. Moving these optimizations to backend code can simplify > shared code, while also making it easier to develop more in-depth

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-29 Thread Vladimir Ivanov
On Thu, 24 Oct 2024 01:26:10 GMT, Jasmine Karthikeyan wrote: >> Hi all, >> This patch adds a new pass to consolidate lowering of complex >> backend-specific code patterns, such as `MacroLogicV` and the optimization >> proposed by #21244. Moving these optimizations to backend code can simplify

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-29 Thread Jatin Bhateja
On Mon, 28 Oct 2024 23:48:48 GMT, Quan Anh Mai wrote: >> Generic vector operand resolution cocretizes generic operands based on type >> agnostic node size, its a post matcher pass, and its job is to replace >> generic MachOper operand nodes with cocrete ones (vec[SDXYZ]) which holds >> precis

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-28 Thread Quan Anh Mai
On Mon, 28 Oct 2024 22:46:55 GMT, Vladimir Ivanov wrote: >>> @jatin-bhateja @iwanowww The application of lowering is very broad as it >>> can help us perform arbitrary transformation as well as take advantages of >>> GVN in the ideal world: >>> >>> 1, Any expansion that can benefit from GVN ca

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-28 Thread Quan Anh Mai
On Sun, 27 Oct 2024 01:22:13 GMT, Jatin Bhateja wrote: >> I believe the matcher only needs the exact type of the node but not its >> inputs. E.g. it should not be an issue if we `AddVB` a `vector` and a >> `vector` into a `vector`. > > Generic vector operand resolution cocretizes generic operan

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-28 Thread Vladimir Ivanov
On Mon, 28 Oct 2024 07:10:59 GMT, Jatin Bhateja wrote: > The application of lowering is very broad as it can help us perform arbitrary > transformation as well as take advantages of GVN @merykitty thanks for the examples. The idea of gradual IR lowering is not new in C2. There are precedents

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-28 Thread Vladimir Ivanov
On Mon, 28 Oct 2024 03:54:06 GMT, Jasmine Karthikeyan wrote: >> @jaskarth thanks for exploring platform-specific lowering! >> >> I briefly looked through the changes, but I didn't get a good understanding >> of its design goals. It's hard to see what use cases it is targeted for when >> only

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-28 Thread Jatin Bhateja
On Sun, 27 Oct 2024 01:55:41 GMT, Jatin Bhateja wrote: >> Thanks for looking at the build changes, @magicus! I've pushed a commit that >> removes the extra newline in the makefiles and adds newlines to the ends of >> files that were missing them. >> >> Thanks for taking a look as well, @meryki

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-27 Thread Quan Anh Mai
On Mon, 28 Oct 2024 03:55:57 GMT, Jasmine Karthikeyan wrote: >> I mean we might want to run another kind of `Ideal` that will replace the >> normal `Ideal` on a node after its lowering. For example, consider this: >> >> vector v; >> u = v.withLane(0, a).withLane(1, b); >> >> This will

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-27 Thread Jasmine Karthikeyan
On Fri, 25 Oct 2024 23:30:52 GMT, Vladimir Ivanov wrote: >> Thanks for looking at the build changes, @magicus! I've pushed a commit that >> removes the extra newline in the makefiles and adds newlines to the ends of >> files that were missing them. >> >> Thanks for taking a look as well, @mery

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-27 Thread Jasmine Karthikeyan
On Thu, 24 Oct 2024 11:51:23 GMT, Quan Anh Mai wrote: >> Ah, do you mean having a method in `Node` that holds the lowering code? I >> was originally planning on doing it this way, but I think it would pose some >> problems where certain nodes' `Lower()` methods would only be overridden on >> c

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-27 Thread Quan Anh Mai
On Sun, 27 Oct 2024 01:55:41 GMT, Jatin Bhateja wrote: >> Thanks for looking at the build changes, @magicus! I've pushed a commit that >> removes the extra newline in the makefiles and adds newlines to the ends of >> files that were missing them. >> >> Thanks for taking a look as well, @meryki

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-26 Thread Jatin Bhateja
On Sat, 26 Oct 2024 02:34:44 GMT, Quan Anh Mai wrote: >>> By allowing lowering to look through VectorReinterpret and break the >>> invariant of Extract nodes that the element types of their inputs and >>> outputs must be the same, we can gvn v1 and v, v2 and v0. >> >> I'd warn against breaking

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-26 Thread Jatin Bhateja
On Thu, 24 Oct 2024 02:14:46 GMT, Jasmine Karthikeyan wrote: >> Build changes look good (but would be slightly better without the extra >> blank line). I have not reviewed the actual hotspot changes. > > Thanks for looking at the build changes, @magicus! I've pushed a commit that > removes the

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-25 Thread Quan Anh Mai
On Fri, 25 Oct 2024 23:30:52 GMT, Vladimir Ivanov wrote: >> Thanks for looking at the build changes, @magicus! I've pushed a commit that >> removes the extra newline in the makefiles and adds newlines to the ends of >> files that were missing them. >> >> Thanks for taking a look as well, @mery

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-25 Thread Quan Anh Mai
On Fri, 25 Oct 2024 22:20:00 GMT, Vladimir Ivanov wrote: >>> Because lowering is a transformation that increases the complexity of the >>> graph. >>> >>> * A `d = ExtractD(z, 4)` expanded into `x = VectorExtract(z, 2); d = >>> ExtractD(x, 0)` increases the number of nodes by 1. >>> * A logic

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-25 Thread Vladimir Ivanov
On Thu, 24 Oct 2024 02:14:46 GMT, Jasmine Karthikeyan wrote: >> Build changes look good (but would be slightly better without the extra >> blank line). I have not reviewed the actual hotspot changes. > > Thanks for looking at the build changes, @magicus! I've pushed a commit that > removes the

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-25 Thread Vladimir Ivanov
On Thu, 24 Oct 2024 02:05:58 GMT, Jatin Bhateja wrote: >> Another reason is that lowering being done late allows us to have more >> freedom to break some invariants of the nodes, such as looking through >> `VectorReinterpret`. An example is this (really crafted) case: >> >> Int256Vector v;

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-24 Thread Quan Anh Mai
On Thu, 24 Oct 2024 02:08:14 GMT, Jasmine Karthikeyan wrote: >> src/hotspot/share/opto/phaseX.cpp line 2277: >> >>> 2275: >>> 2276: // Try to find an existing version of the same node >>> 2277: Node* existing = _igvn->hash_find_insert(n); >> >> I think it would be easier if you have a swi

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-24 Thread Jasmine Karthikeyan
On Mon, 21 Oct 2024 06:12:01 GMT, Quan Anh Mai wrote: >> Jasmine Karthikeyan has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Address some changes from code review > > src/hotspot/share/opto/compile.cpp line 2464: > >> 2462: { >> 2463:

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-23 Thread Jatin Bhateja
On Thu, 24 Oct 2024 02:13:20 GMT, Jasmine Karthikeyan wrote: > I think we shouldn't run `Ideal` on the graph, because there is a chance that > it could undo the lowering changes that we just did. This gives lowering more > freedom to change the graph in different ways that would otherwise be u

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-23 Thread Jasmine Karthikeyan
On Mon, 21 Oct 2024 12:55:39 GMT, Magnus Ihse Bursie wrote: >> Jasmine Karthikeyan has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Address some changes from code review > > Build changes look good (but would be slightly better without th

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-23 Thread Jasmine Karthikeyan
On Wed, 23 Oct 2024 07:57:05 GMT, Jatin Bhateja wrote: >> Jasmine Karthikeyan has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Address some changes from code review > > src/hotspot/share/opto/phaseX.cpp line 2301: > >> 2299: while(_igv

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-23 Thread Jasmine Karthikeyan
On Mon, 21 Oct 2024 06:11:26 GMT, Quan Anh Mai wrote: >> Jasmine Karthikeyan has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Address some changes from code review > > src/hotspot/share/opto/phaseX.cpp line 2277: > >> 2275: >> 2276: /

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-23 Thread Jatin Bhateja
On Wed, 23 Oct 2024 17:39:22 GMT, Quan Anh Mai wrote: >> Because lowering is a transformation that increases the complexity of the >> graph. >> >> - A `d = ExtractD(z, 4)` expanded into `x = VectorExtract(z, 2); d = >> ExtractD(x, 0)` increases the number of nodes by 1. >> - A logic cone tran

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering [v2]

2024-10-23 Thread Jasmine Karthikeyan
> Hi all, > This patch adds a new pass to consolidate lowering of complex > backend-specific code patterns, such as `MacroLogicV` and the optimization > proposed by #21244. Moving these optimizations to backend code can simplify > shared code, while also making it easier to develop more in-depth

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering

2024-10-23 Thread Quan Anh Mai
On Wed, 23 Oct 2024 17:28:25 GMT, Quan Anh Mai wrote: >> src/hotspot/share/opto/compile.cpp line 2466: >> >>> 2464: print_method(PHASE_BEFORE_LOWERING, 3); >>> 2465: >>> 2466: PhaseLowering lower(&igvn); >> >> Any specific reason to have lowering after loop optimizations ? >> Lowered n

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering

2024-10-23 Thread Quan Anh Mai
On Wed, 23 Oct 2024 08:10:38 GMT, Jatin Bhateja wrote: >> Hi all, >> This patch adds a new pass to consolidate lowering of complex >> backend-specific code patterns, such as `MacroLogicV` and the optimization >> proposed by #21244. Moving these optimizations to backend code can simplify >> sha

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering

2024-10-23 Thread Jatin Bhateja
On Mon, 21 Oct 2024 04:11:03 GMT, Jasmine Karthikeyan wrote: > Hi all, > This patch adds a new pass to consolidate lowering of complex > backend-specific code patterns, such as `MacroLogicV` and the optimization > proposed by #21244. Moving these optimizations to backend code can simplify > s

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering

2024-10-21 Thread Jatin Bhateja
On Mon, 21 Oct 2024 04:11:03 GMT, Jasmine Karthikeyan wrote: > Hi all, > This patch adds a new pass to consolidate lowering of complex > backend-specific code patterns, such as `MacroLogicV` and the optimization > proposed by #21244. Moving these optimizations to backend code can simplify > s

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering

2024-10-21 Thread Magnus Ihse Bursie
On Mon, 21 Oct 2024 04:11:03 GMT, Jasmine Karthikeyan wrote: > Hi all, > This patch adds a new pass to consolidate lowering of complex > backend-specific code patterns, such as `MacroLogicV` and the optimization > proposed by #21244. Moving these optimizations to backend code can simplify > s

Re: RFR: 8342662: C2: Add new phase for backend-specific lowering

2024-10-20 Thread Quan Anh Mai
On Mon, 21 Oct 2024 04:11:03 GMT, Jasmine Karthikeyan wrote: > Hi all, > This patch adds a new pass to consolidate lowering of complex > backend-specific code patterns, such as `MacroLogicV` and the optimization > proposed by #21244. Moving these optimizations to backend code can simplify > s

RFR: 8342662: C2: Add new phase for backend-specific lowering

2024-10-20 Thread Jasmine Karthikeyan
Hi all, This patch adds a new pass to consolidate lowering of complex backend-specific code patterns, such as `MacroLogicV` and the optimization proposed by #21244. Moving these optimizations to backend code can simplify shared code, while also making it easier to develop more in-depth optimizat