LLVM should already know that thanks to TBAA. I recall you made the lookup table a tuple for this reason.
The @code_llvm
seems to show the table as a constant (see the @_j_const1 = private unnamed_addr constant [256 x i64]
):
; julia> @code_llvm debuginfo=:none dump_module=true exp(1.3)
; ModuleID = 'exp'
source_filename = "exp"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@_j_const1 = private unnamed_addr constant [256 x i64] [i64 0, i64 -6142897681236050754, i64 -7250770945965870283, i64 -6102340764187295104, i64 -5926688068634967968, i64 7304899980040453068, i64 -6368016111728951420, i64 -8881012293317012303, i64 -8254999500979600012, i64 -6552626363961172088, i64 -6282397874615617827, i64 -8998055904294033354, i64 7025764149530827720, i64 -6579597711007938593, i64 -7980204547173321853, i64 -8804350596743218919, i64 -7448754392280758001, i64 -7714454019193410427, i64 -8065722004454357001, i64 -6768672491432223253, i64 4625447420914028962, i64 -6507437967993230908, i64 -5890431894142659814, i64 -8268319537450507458, i64 -6588463881359566000, i64 -6800120033530991947, i64 -5804811450238357045, i64 -5872352343580605270, i64 -6457807158549860897, i64 -6264139202367114963, i64 -9060861363044905391, i64 6409016600702337986, i64 -6083955485986434694, i64 8111403855127100352, i64 -6381166394007056919, i64 -7736736493901226705, i64 -8191586632022897803, i64 -7516033227277759972, i64 -6678350199451788077, i64 -8069948950579766165, i64 -7061129063625606742, i64 -6592741095162757082, i64 -6408079866331342564, i64 -6772857755046195636, i64 -8232010316118848298, i64 -7831176193893685223, i64 -9033623501717775210, i64 -8272501334612569391, i64 -7371767541561728456, i64 -8448113947327720438, i64 -8448100004451408321, i64 -7790560478176031115, i64 -9029036357118165795, i64 -7060949263364268247, i64 -6714157997352459392, i64 -6106157914738541713, i64 -8785785521786855711, i64 -6678086686518210798, i64 -5786359712113305201, i64 -6524935764185769170, i64 -8069656110822063349, i64 -7128389424309332599, i64 8197374510970580822, i64 -5862849083290580886, i64 -8722620365124028651, i64 -8551469058473676035, i64 -8461382505746081743, i64 -6786028844707419599, i64 -7844360117898963201, i64 -6114963182057162196, i64 -6259063651402866704, i64 -6272559691648300998, i64 -6565278868775982646, i64 -6700372018822482615, i64 -6866990326028576667, i64 -6691335021213433618, i64 -5961736921781264394, i64 -7691104178333258508, i64 -6880441204378195740, i64 9215438945652695411, i64 -8443160070567349214, i64 -6249891888336449164, i64 -6623675452593766373, i64 -8371056861974650844, i64 -5835514984389988823, i64 -6641643988865956215, i64 -6087685864315377514, i64 -8609686243585508908, i64 5229890865167698221, i64 -5875970320184651215, i64 -7163984275856097193, i64 -6781162727645957578, i64 8341940443189165264, i64 -6119102295816622383, i64 -7366583685646658594, i64 -6074034843053869098, i64 9026550499758189095, i64 -8046579852547473132, i64 -7429570825608635123, i64 -6528834979095860226, i64 -6510804616381387610, i64 8801450124166640110, i64 -6330628572909181375, i64 -6024367703840567570, i64 -6060380362815746175, i64 -8676955564519543513, i64 -6294535135968783858, i64 -6375583659597426479, i64 -7370862863470745638, i64 -6366543788560431922, i64 -9037161965233387523, i64 -6627719717761120309, i64 -7622998743989070807, i64 -6753787479772857854, i64 4343098583035758263, i64 -6803293868782941294, i64 -7231119162382409400, i64 -6231303328905761936, i64 -6483488146515895288, i64 -7041917693342124300, i64 -6469943688130046588, i64 -7474229506805782019, i64 -6276255061881601249, i64 -6735605233889800266, i64 -6762609795605913052, i64 -6316736350258711563, i64 6932870882017454451, i64 -8645063054064708296, i64 -6767044787892700212, i64 8806419991805368126, i64 -5933844273508394306, i64 -7172316809019492795, i64 -5888773506129913298, i64 -6366137610341369116, i64 -6199486920510040957, i64 6473659981986279047, i64 -6077854580833755277, i64 -6415606906510192503, i64 -6366049616388587149, i64 -8050378134830724099, i64 -6347999685386278968, i64 -7244198172700217847, i64 -7464856667543413441, i64 -7834133901593535242, i64 -6127251658798071418, i64 -6771248372730376230, i64 -6982899473543282382, i64 -7946651663102671120, i64 8095188389446241890, i64 -6059607010233432944, i64 -6428883901107791343, i64 -7752923863426464039, i64 -6820660362739921390, i64 -7379088288885685769, i64 -6212637507786127444, i64 -5825309412123780320, i64 -6910658344377871636, i64 -8802151559561370570, i64 -7378995398493706599, i64 -7108760691389474801, i64 -7572612672765910821, i64 -7005140288556099720, i64 -5915250296514853749, i64 -6595274906835327272, i64 -8806523339128080586, i64 -7667093597184316278, i64 -6838412177916690491, i64 -6113313498326224927, i64 -5870099926971726364, i64 -6302426247689430812, i64 -5964636979952332274, i64 -5825006043503628110, i64 -6811274961439797681, i64 8982868384806478498, i64 -6392401237235857479, i64 -6838238041659408884, i64 8969416262126137488, i64 -6522946791140509484, i64 8658707270930211619, i64 -6135597733315612003, i64 -6459837081213606556, i64 -7175889542941067077, i64 -7621725973128794829, i64 -6725489660316480809, i64 -6815541611708144292, i64 7280745317454340178, i64 -7220825332701416616, i64 -6518243586222248360, i64 -7999907604237517377, i64 -8603369639986762054, i64 -6333535058395925639, i64 -7499946937261742220, i64 -7517940855771311187, i64 -6509114003713494274, i64 -6765798591269325211, i64 -7720541065239164590, i64 -5847022917240547846, i64 -6045160541700798032, i64 -6788233664789128903, i64 -7878083902748637910, i64 -5955025933407920570, i64 -6752142082256188957, i64 -6878221829729614263, i64 -5779322421507363042, i64 -9062425393511022126, i64 -5779280051447815674, i64 -6878137089299898872, i64 -6297151408470641860, i64 -9143404986241822052, i64 -6589842552810478293, i64 -7256353794806525830, i64 -7985915373285606622, i64 -7886814561870294709, i64 -6310533014060742350, i64 8191079523077777333, i64 -6193395890803063590, i64 8434317553931620457, i64 -6026718935264717196, i64 -6301416538828323847, i64 -6702214872381543565, i64 -6796768371535279749, i64 -7683955345205966488, i64 -6819242003766867471, i64 -7791997250069421610, i64 -9012450415488555897, i64 6912300261044315859, i64 -6377799784458517609, i64 -7346051188594352011, i64 -7192906224468544891, i64 -6751530822979124460, i64 -7863897231554661280, i64 -6796521358938601897, i64 -6400181769089606818, i64 -5931784523324228330, i64 -6616308720119471832, i64 -6697350504632619503, i64 -8962638046037327882, i64 -6161375944097960587, i64 -7863713406807225213, i64 -6377502270446258369, i64 -6863867707811131175, i64 -7742046249523819922, i64 -6791763279119226896, i64 -7940157671492516592, i64 -7075442966682052057, i64 -6453922577827610327, i64 -7804978761666151785, i64 -5990004343194160525, i64 -7359074796829784768, i64 -6940216133781273352, i64 -6832105780228080109, i64 -5841289834741351288, i64 -8696547905883959080, i64 -5989860371902311149, i64 7129149566058721777, i64 8408196149339104217]
define double @julia_exp_4268(double %0) {
top:
%1 = fmul contract double %0, 0x40771547652B82FE
%2 = fadd contract double %1, 0x4338000000000000
%3 = bitcast double %2 to i64
%4 = trunc i64 %3 to i32
%5 = fadd double %2, 0xC338000000000000
%6 = fmul contract double %5, 0x3F662E42FEF80000
%7 = fsub contract double %0, %6
%8 = fmul contract double %5, 0x3D31CF79ABC9E3B4
%9 = fsub contract double %7, %8
%10 = ashr i32 %4, 8
%11 = and i64 %3, 255
%12 = getelementptr inbounds [256 x i64], [256 x i64]* @_j_const1, i64 0, i64 %11
%13 = load i64, i64* %12, align 8
%14 = and i64 %13, 4503599627370495
%15 = or i64 %14, 4607182418800017408
%16 = bitcast i64 %15 to double
%17 = lshr i64 %13, 8
%18 = or i64 %17, 4323455642275676160
%19 = bitcast i64 %18 to double
%20 = fmul contract double %9, 0x3FA5555565BBF98F
%21 = fadd contract double %20, 0x3FC555557E55EFED
%22 = fmul contract double %9, %21
%23 = fadd contract double %22, 0x3FDFFFFFFFFFFFFB
%24 = fmul contract double %9, %23
%25 = fadd contract double %24, 0x3FEFFFFFFFFFFFB1
%26 = fmul double %9, %25
%27 = fmul contract double %26, %16
%28 = fadd contract double %27, %19
%29 = fadd double %28, %16
%30 = call double @llvm.fabs.f64(double %0)
%31 = fcmp ugt double %30, 0x4086232BDD7ABCD2
br i1 %31, label %L44, label %L68
L44: ; preds = %top
%32 = fcmp ult double %0, 0x40862E42FEFA39EF
br i1 %32, label %L47, label %L46
L46: ; preds = %L47, %L44
%merge = phi double [ 0x7FF0000000000000, %L44 ], [ 0.000000e+00, %L47 ]
ret double %merge
L47: ; preds = %L44
%33 = fcmp ugt double %0, 0xC0874910D52D3052
br i1 %33, label %L50, label %L46
L50: ; preds = %L47
%34 = icmp sgt i32 %4, -13313
br i1 %34, label %L68, label %L53
L53: ; preds = %L50
%narrow = add nsw i32 %10, 53
%35 = zext i32 %narrow to i64
%36 = shl i64 %35, 52
%37 = bitcast double %29 to i64
%38 = add i64 %36, %37
%39 = bitcast i64 %38 to double
%40 = fmul double %39, 0x3CA0000000000000
ret double %40
L68: ; preds = %L50, %top
%41 = zext i32 %10 to i64
%42 = shl i64 %41, 52
%43 = bitcast double %29 to i64
%44 = add i64 %42, %43
%45 = bitcast i64 %44 to double
ret double %45
}
define nonnull {}* @jfptr_exp_4269({}* %0, {}** %1, i32 %2) #0 {
top:
%thread_ptr = call i8* asm "movq %fs:0, $0", "=r"() #5
%ptls_i8 = getelementptr i8, i8* %thread_ptr, i64 -32768
%3 = bitcast {}** %1 to double**
%4 = load double*, double** %3, align 8
%5 = load double, double* %4, align 8
%6 = call double @julia_exp_4268(double %5)
%7 = call noalias nonnull {}* @jl_gc_pool_alloc(i8* %ptls_i8, i32 1400, i32 16) #1
%8 = bitcast {}* %7 to i64*
%9 = getelementptr inbounds i64, i64* %8, i64 -1
store atomic i64 140545523352272, i64* %9 unordered, align 8
%10 = bitcast {}* %7 to double*
store double %6, double* %10, align 8
ret {}* %7
}
; Function Attrs: allocsize(1)
declare noalias nonnull {}* @julia.gc_alloc_obj(i8*, i64, {}*) #1
; Function Attrs: nounwind readnone speculatable willreturn
declare double @llvm.fabs.f64(double) #2
; Function Attrs: nounwind readnone speculatable willreturn
declare double @llvm.pow.f64(double, double) #2
; Function Attrs: argmemonly nounwind willreturn
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #3
; Function Attrs: argmemonly nounwind willreturn
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #3
; Function Attrs: inaccessiblemem_or_argmemonly
declare void @jl_gc_queue_root({}*) #4
; Function Attrs: allocsize(1)
declare noalias nonnull {}* @jl_gc_pool_alloc(i8*, i32, i32) #1
; Function Attrs: allocsize(1)
declare noalias nonnull {}* @jl_gc_big_alloc(i8*, i64) #1
; Function Attrs: allocsize(1)
declare noalias nonnull {}* @julia.gc_alloc_bytes(i8*, i64) #1
attributes #0 = { "thunk" }
attributes #1 = { allocsize(1) }
attributes #2 = { nounwind readnone speculatable willreturn }
attributes #3 = { argmemonly nounwind willreturn }
attributes #4 = { inaccessiblemem_or_argmemonly }
attributes #5 = { nounwind }
!llvm.module.flags = !{!0, !1}
!0 = !{i32 2, !"Dwarf Version", i32 4}
!1 = !{i32 1, !"Debug Info Version", i32 3}
So I don’t know why it would have a problem. Maybe it’s an LLVM bug?
I need to learn more about how LLVM works so I can look into things like this.
That reminds me there was a Julia issue where Keno was going to walk me through an LLVM fix that I need to get back to…