www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - __assume

reply "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= writes:
Commercial compilers provide a way to tell the compiler 
invariants that are known to always hold, e.g. MSVC provides 
__assume(x). LLVM eliminates such assumptions prematurely 
according to this link:

https://github.com/preames/llvm-assume-hack

Does this also affect:

http://llvm.org/docs/LangRef.html#llvm-assume-intrinsic

?

Does LDC provide some means for providing assumptions to the 
compiler, for library authors? One use case is to provide 
assumptions about alignment of void pointers and similar 
constrains that are known to hold for library ADTs.
Feb 20 2015
next sibling parent David Nadlinger via digitalmars-d-ldc <digitalmars-d-ldc puremagic.com> writes:
On 20 Feb 2015, at 10:33, via digitalmars-d-ldc wrote:
 Does LDC provide some means for providing assumptions to the compiler, 
 for library authors? One use case is to provide assumptions about 
 alignment of void pointers and similar constrains that are known to 
 hold for library ADTs.
Not yet. I wondered how to best implement this a while back, but decided that I needed to have a more in-depth look at the related parts of the LLVM infrastructure to be able to decide on the best design. I didn't quite get around to that since. It seems like Rust chose a very simple implementation (https://github.com/rust-lang/rust/issues/18051), which would be trivial to add to LDC's druntime. Pull requests are very welcome, as always. Cheers, David
Feb 20 2015
prev sibling parent reply David Nadlinger via digitalmars-d-ldc <digitalmars-d-ldc puremagic.com> writes:
On 20 Feb 2015, at 10:33, via digitalmars-d-ldc wrote:
 Does LDC provide some means for providing assumptions to the compiler,
 for library authors? One use case is to provide assumptions about
 alignment of void pointers and similar constrains that are known to
 hold for library ADTs.
Not yet. I wondered how to best implement this a while back, but decided that I needed to have a more in-depth look at the related parts of the LLVM infrastructure to be able to decide on the best design. I didn't quite get around to that since. It seems like Rust chose a very simple implementation (https://github.com/rust-lang/rust/issues/18051), which would be trivial to add to LDC's druntime. Pull requests are very welcome, as always. Cheers, David
Feb 21 2015
parent "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= writes:
On Saturday, 21 February 2015 at 17:34:32 UTC, David Nadlinger 
wrote:
 It seems like Rust chose a very simple implementation
 (https://github.com/rust-lang/rust/issues/18051), which would 
 be trivial
 to add to LDC's druntime. Pull requests are very welcome, as 
 always.
Hm... yes... the argument might be reduced to "true", but maybe that is ok.
Feb 21 2015