Why do you want to disable this optimization?
-Tom
> Neil
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm...@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Do you have an LLVM IR example where this happens when you don't want
it to?
-Tom
This won’t happen with volatile load/store
-Matt
On Apr 17, 2019, at 5:02 AM, Arsenault, Matthew via llvm-dev <llvm...@lists.llvm.org> wrote:This won’t happen with volatile load/store
struct {volatile int a : 12;volatile int b : 4;} s;
-Matt
On Apr 17, 2019, at 9:53 AM, Jameson Nash <vtj...@gmail.com> wrote:The lang ref promises that, "the backend should never ... merge target-legal volatile load/store instructions". Which I've usually assumed meant that it was promised? Just curious if you thought this left some wiggle room for some optimizations, since my impression was that someone wanted to let you know that it's dependable. Likewise, there's also the clause that "The optimizers must not change the number of volatile operations", which doesn't seem to explicitly forbid merging, but does seem to me like it would make it difficult to find a case where it would be profitable.
On Apr 17, 2019, at 10:00 AM, Neil Ryan <neil...@cs.washington.edu> wrote:So, volatile’s been a fine solution — the issue is volatile pointers would perform the load every time; ideally memory accesses would be able to be cached. This is why I’ve been leaning towards disabling the part of instcombine that combines memory accesses instead of using volatile — there should be better performance.
On Apr 17, 2019, at 10:06 AM, Neil Ryan <neil...@cs.washington.edu> wrote:
Why do you want this?
The goal is to share arrays between multiple tiles on a manycore architecture by splitting arrays between tiles. With a DRF memory model, it makes sense to elide multiple loads to the same memory location between barriers.; IIRC the semantics for volatile don’t allow this eliding.
On Apr 17, 2019, at 9:35 AM, JF Bastien via llvm-dev <llvm...@lists.llvm.org> wrote:
On Apr 17, 2019, at 5:02 AM, Arsenault, Matthew via llvm-dev <llvm...@lists.llvm.org> wrote:This won’t happen with volatile load/storeThis is mostly true today, but AFAICT the LLVM memory model doesn’t actually offer this guarantee. It merely says that LLVM treats volatile like C / C++ treats volatile… which isn’t much of a guarantee because C / C++ volatile doesn’t normatively mean anything. Specifically, we cannot really honor this when volatile bitfields are used for which memory operations don’t exist:struct {volatile int a : 12;volatile int b : 4;} s;As things stand, we haven’t promised that we won’t combine adjacent volatile stores, and C / C++ certainly allow us to do so. I don’t think it would be a good idea to do so, but we certainly could.
On Apr 17, 2019, at 10:42 AM, Amara Emerson <aeme...@apple.com> wrote:Is this really true? The writes to two volatile variables are sequenced and can’t be re-ordered since they can have side effects, and so merging adjacent volatile stores would break this.On Apr 17, 2019, at 9:35 AM, JF Bastien via llvm-dev <llvm...@lists.llvm.org> wrote:
On Apr 17, 2019, at 5:02 AM, Arsenault, Matthew via llvm-dev <llvm...@lists.llvm.org> wrote:This won’t happen with volatile load/storeThis is mostly true today, but AFAICT the LLVM memory model doesn’t actually offer this guarantee. It merely says that LLVM treats volatile like C / C++ treats volatile… which isn’t much of a guarantee because C / C++ volatile doesn’t normatively mean anything. Specifically, we cannot really honor this when volatile bitfields are used for which memory operations don’t exist:struct {volatile int a : 12;volatile int b : 4;} s;As things stand, we haven’t promised that we won’t combine adjacent volatile stores, and C / C++ certainly allow us to do so. I don’t think it would be a good idea to do so, but we certainly could.
On Apr 17, 2019, at 10:40 AM, Neil Ryan <neil...@cs.washington.edu> wrote:
But why is it desirable to avoid combining adjacent stores? If you’ve got DRF code then the combination can’t be observed.
It’s more that the consecutive stores would be going to different tiles. If multiple stores are combined in IR, I don’t think they’d be able to decoupled in IR, unless there’s a way to always determine which global object an arbitrary GEP is pointing to.
Why do you want this?
But why is it desirable to avoid combining adjacent stores? If you’ve got DRF code then the combination can’t be observed.
This is really a codegen problem. You can decompose the load/store however you like in the backend. InstCombine should still combine the loads as a canonicalization.
-Matt
I’m not sure what you mean by this. The type in memory doesn’t really mean anything, and no information is lost. You can still tell (for optimizations) some information about the underlying IR object from the MachineMemOperand, which is mostly used for alias analysis.
-Matt
From: Neil Ryan <neil...@cs.washington.edu>
Date: Thursday, April 18, 2019 at 9:59 PM
To: llvm-dev <llvm...@lists.llvm.org>, "tste...@redhat.com" <tste...@redhat.com>, "Arsenault, Matthew" <Matthew....@amd.com>
Subject: Re: [llvm-dev] Disable combining of loads and stores in instcombine
IIRC it’s not strictly possible to determine what array a load/store is based on. I don’t believe the decomposition is always possible, as information is lost when accesses are combined.
Neil