Yes, but this only exists in version 8 onwards and is undocumented:

```
Compile`CompilerFunctions[] // Sort
```

giving, for reference:

```
{Abs, AddTo, And, Append, AppendTo, Apply, ArcCos, ArcCosh, ArcCot, ArcCoth, ArcCsc,
ArcCsch, ArcSec, ArcSech, ArcSin, ArcSinh, ArcTan, ArcTanh, Arg, Array, ArrayDepth,
Internal`Bag, Internal`BagPart, BitAnd, BitNot, BitOr, BitXor, Block, BlockRandom, Boole,
Break, Cases, Catch, Ceiling, Chop, Internal`CompileError, System`Private`CompileSymbol,
Complement, ComposeList, CompoundExpression, Conjugate, ConjugateTranspose, Continue,
Cos, Cosh, Cot, Coth, Count, Csc, Csch, Decrement, Delete, DeleteCases, Dimensions,
Divide, DivideBy, Do, Dot, Drop, Equal, Erf, Erfc, EvenQ, Exp, Fibonacci, First,
FixedPoint, FixedPointList, Flatten, NDSolve`FEM`FlattenAll, Floor, Fold, FoldList, For,
FractionalPart, FreeQ, Compile`GetElement, Goto, Greater, GreaterEqual, Gudermannian,
Haversine, If, Im, Implies, Increment, Inequality, Compile`InnerDo, Insert,
IntegerDigits, IntegerPart, Intersection, InverseGudermannian, InverseHaversine,
Compile`IteratorCount, Join, Label, Last, Length, Less, LessEqual, List, Log, Log10,
Log2, LucasL, Map, MapAll, MapAt, MapIndexed, MapThread, NDSolve`FEM`MapThreadDot,
MatrixQ, Max, MemberQ, Min, Minus, Mod, Compile`Mod1, Module, Most, N, Negative, Nest,
NestList, NonNegative, Not, OddQ, Or, OrderedQ, Out, Outer, Part, Partition, Piecewise,
Plus, Position, Positive, Power, PreDecrement, PreIncrement, Prepend, PrependTo, Product,
Quotient, Random, RandomChoice, RandomComplex, RandomInteger, RandomReal, RandomSample,
RandomVariate, Range, Re, ReplacePart, Rest, Return, Reverse, RotateLeft, RotateRight,
Round, RuleCondition, SameQ, Scan, Sec, Sech, SeedRandom, Select, Set, SetDelayed,
Compile`SetIterate, Sign, Sin, Sinc, Sinh, Sort, Sqrt, Internal`Square, Internal`StuffBag,
Subtract, SubtractFrom, Sum, Switch, Table, Take, Tan, Tanh, TensorRank, Throw, Times,
TimesBy, Tr, Transpose, Unequal, Union, Unitize, UnitStep, UnsameQ, VectorQ, Which,
While, With, Xor}
```

As of *Mathematica* 10.0.2, there are also the following functions:

```
{Gamma, Indexed, LogGamma, LogisticSigmoid, Internal`ReciprocalSqrt}
```

As of *Mathematica* 11, there are also the following functions:

```
{Internal`Expm1, Internal`Log1p, Ramp}
```

As of *Mathematica* 11.2, there are also the following functions:

```
{RealAbs, RealSign}
```

**About **`Tr`

:

Please note that `Tr`

appears in this list, but cannot actually be compiled without a call to `MainEvaluate[]`

. It is unclear if this is deliberate or a bug.

## Edit: additional functions

I have just discovered the symbol `Internal`CompileValues`

, which provides various definitions and function calls needed to compile further functions not in the list above. Using the following code,

```
Internal`CompileValues[]; (* to trigger auto-load *)
ClearAttributes[Internal`CompileValues, ReadProtected];
syms = DownValues[Internal`CompileValues] /.
HoldPattern[Verbatim[HoldPattern][Internal`CompileValues[sym_]] :> _] :>
sym;
Complement[syms, Compile`CompilerFunctions[]]
```

we get some more compilable functions as follows:

```
{Accumulate, ConstantArray, Cross, Depth, Det, DiagonalMatrix,
Differences, NDSolve`FEM`FEMDot, NDSolve`FEM`FEMHold,
NDSolve`FEM`FEMInverse, NDSolve`FEM`FEMPart, NDSolve`FEM`FEMTDot,
NDSolve`FEM`FEMTotalTimes, NDSolve`FEM`FEMZeroMatrix, FromDigits,
Identity, IdentityMatrix, Inverse, LinearSolve, Mean, Median, Nand,
NestWhile, NestWhileList, Nor, Norm, Ordering, PadLeft, PadRight,
Permutations, Ratios, Signature, SquareWave, StandardDeviation,
Tally, Total, TrueQ, Variance}
```

Looking at the definition of `Internal`CompileValues[sym]`

for *sym* in the list above will provide some additional information about how these functions are compiled. This can range from type information (for e.g. `Inverse`

), through to an implementation in terms of lower-level functions (e.g. `NestWhileList`

). One can presumably also make one's own implementations of non-compilable functions using this mechanism, giving `Compile`

the ability to compile a wider range of functions than it usually would be able to.

As of *Mathematica* 10.3, there are also the following functions:

```
{DeleteDuplicates, Region`Mesh`SmallMatrixRank,
Region`Mesh`SmallQRSolve, Region`Mesh`SmallSingularValues,
Region`Mesh`SmallSingularValueSystem, Region`Mesh`SmallSVDSolve,
NDSolve`SwitchingVariable}
```

As of *Mathematica* 11, there are also the following functions:

```
{NearestFunction, RegionDistanceFunction, RegionMemberFunction, RegionNearestFunction}
```

## Edit 2: the meaning of the second list

In response to a recent question, I want to be clear that the presence of a function in the second list given above does not necessarily mean it can be compiled into a form free of `MainEvaluate`

calls. If a top-level function is already highly optimized (as e.g. `LinearSolve`

is), the purpose of `Internal`CompileValues[func]`

may be solely to provide type information on the return value, assuming that this can be inferred from the types of the arguments or some other salient information. This mechanism allows more complex functions that call these highly-optimized top-level functions to be compiled more completely since there is no longer any question of what the return type may be and so further *unnecessary* `MainEvaluate`

calls may be avoided. It *does not* imply that the use of `MainEvaluate`

is unnecessary *to call the function itself*.

Hi Oleksandr, can you confirm

`FromDigits`

is compilable? I tried`Compile[{{x, _Integer, 1}}, FromDigits[x, 2]]`

, but it came out as a "MainEvaluate" (an instruction`{47, FromDigits, ...}`

). – Silvia – 2014-01-25T08:50:40.7631@Silvia no,

`FromDigits`

is not compilable. Its presence in the second list merely indicates that the compiler knows what types it accepts and returns. Namely, given an integer input of rank $n>0$, it produces an integer output of rank $n-1$. – Oleksandr R. – 2014-02-02T15:44:25.460@OleksandrR. I see. Thanks! – Silvia – 2014-02-03T04:02:33.593

@OleksandrR. Can

– MOON – 2014-12-21T05:57:35.840`SetDelayed`

be compiled? here it seems it can't be: http://mathematica.stackexchange.com/questions/2830/can-setdelayed-be-compiled@yashar the VM does not have the same evaluation semantics as the top-level evaluator. So, when

`SetDelayed`

gets compiled, its behavior will be different to that experienced in top-level code. But, the compiler does convert it to bytecode, albeit not completely faithfully, depending on the intent of the code being compiled. – Oleksandr R. – 2014-12-22T15:42:24.053A few more functions have appeared since v8, including

`Indexed`

and`Gamma`

(updated from answers below) – dr.blochwave – 2015-03-02T13:56:33.377I thought I'd seen a documented list somewhere or other?? – Mike Honeychurch – 2012-02-01T03:57:42.820

7Interesting,

`Total[]`

isn't compilable, but`Plus`

and`Apply`

are... – J. M.'s ennui – 2012-02-01T04:33:35.9509It looks like you've found a counterexample. Indeed,

`MemberQ[Compile`CompilerFunctions[], Total] == False`

, but in practice Total gets compiled down to a call to the internal kernel function`TotalAll`

. Why`Total`

is not included in the list, I have no idea. – Oleksandr R. – 2012-02-01T04:45:17.750@Mike There used to be a documented list somewhere on wri.com but it was removed shortly after v6 came out. I used to have it bookmarked some years ago, but then it just vanished. – Szabolcs – 2012-02-01T08:30:10.883

Actually whether a function is compilable or not (or what it gets compiled to) depends on the context and the argument types (see my answer for an example). – Szabolcs – 2012-02-01T09:02:05.633

@Szabolcs: do you still have the URL? We can try checking the Wayback Machine to see if it was archived... – J. M.'s ennui – 2012-02-01T11:04:13.913

@J.M. No, unfortunately I lost that Firefox profile. Also,

`Compile`

must have changed alotsince then. – Szabolcs – 2012-02-01T11:08:48.5001

@MikeHoneychurch, Ted Ersek posted the old list (version 3/4 vintage) on his website. See here. There have been quite a few changes since then, though.

– Oleksandr R. – 2012-02-01T23:47:21.0778To whoever downvoted this: would you be so kind as to let me know what your concerns were and perhaps suggest how I could improve my answers in future? Many thanks. – Oleksandr R. – 2012-08-18T23:10:20.790

@OleksandrR. maybe that is where I remember seeing it, although I thought it was in Mma documentation. – Mike Honeychurch – 2012-02-02T00:56:17.360

Note that Gamma only supports 1 argument, rather than multiple arguments for the incomplete gamma functions. But still, nice to have. – Ian Hincks – 2016-06-10T18:31:53.417

@OleksandrR. Interesting that Internal`Bag functions are available for compile. Cool stuff. Makes me wonder if these are being used automagically under the hood when MMA compiles functions involving certain list structures---or if this is largely unexplored territory. – telefunkenvf14 – 2012-12-07T12:57:47.987

@telefunkenvf14 they are used in that way, yes (check out

– Oleksandr R. – 2012-12-07T14:07:21.177`Internal`CompileValues[NestWhileList]`

, for instance). That's actually how I first realised these were usable within the VM--noticing that they sometimes appear in the compiled bytecode. By the way, did you see this?@OleksandrR. You rock! Thanks for pointing me toward that link. Do you know much about System

`Utilites`

Hash? I'm curious about Bags and Hashing and how the two might possibly relate. I'd also like to see more examples of how they can both be used, beyond toy examples. (But I'm afraid I don't really know enough to ask a question about them.) <--- That's me prodding you to ask a cool question or two so the rest of us can learn... :) – telefunkenvf14 – 2012-12-07T20:03:26.4831

@telefunkenvf14 I think there is not much more to be said about

– Oleksandr R. – 2012-12-09T06:30:03.323`System`Utilities`HashTable*`

beyond what I already wrote here. That object definitely isn't related to the`Internal`Bag`

; they are totally different data structures (also, the`HashTable`

cannot be used in compiled code). Hash tables and linked lists are well-known data structures in computer science, so you will find a lot of information already out there. Any more specific questions... just ask!