Avoid allocations on broadcasted getindex()

If I have the code below is there someway to do this without allocating intermediate arrays? It feels like it should be possible but I cant figure it out. I can do this without allocating if I was indexing with a range, but my problem is such that I index with a random-ish array of integers that is much longer than the size of the vector. Any help would be greatly appreciated!

phi = rand(500,500)
N = 10000000; m = 32, n = 51
is = rand(1:500, N); js = rand(1:500, N); vals = rand(N);
phi_n = view(phi:,n); phi_m = view(phi,:,m)
## Specifically this calculation -- allocates on the getindex.()
mcc_val = sum(vals .* getindex.(Ref(phi_n), is) .*
                 getindex.(Ref(phi_m), js))

Realized for-loop works at the cost of my code looking uglier and having to re-arrange some structs.

Something like this should work:

mcc_val = sum(vals[k] * phi[n, is[k]] * phi[m, js[k]] for k in 1:N)

Would that look “less ugly” to you than a for loop?