On Tue, Oct 16, 2012 at 11:27 AM, Marc Zyngier <marc.zyngier@xxxxxxx> wrote: > On 16/10/12 14:46, Christoffer Dall wrote: >> On Mon, Oct 15, 2012 at 11:19 AM, Marc Zyngier <marc.zyngier@xxxxxxx> wrote: >>> The use of VCPU_*_MODE in register manipulation code is not really >>> necessary, and possibly costly (table lookup doesn't come for free). >> >> the reason why the table is there is that previous reviewers felt the >> series of branches with a lot of room for misprediction wold be >> harmfully slow and therefore suggested the lookup table. I'm curious, >> do you feel otherwise? > > You shouldn't be so pessimistic about the compiler: > > c0020824 <vcpu_reg>: > c0020824: b410 push {r4} > c0020826: f8d0 20d0 ldr.w r2, [r0, #208] ; 0xd0 > c002082a: f002 021f and.w r2, r2, #31 > c002082e: f1a2 0310 sub.w r3, r2, #16 > c0020832: 2b0f cmp r3, #15 > c0020834: d81b bhi.n c002086e <vcpu_reg+0x4a> > c0020836: e8df f003 tbb [pc, r3] > c002083a: 1717 .short 0x1717 > c002083c: 1a1a1717 .word 0x1a1a1717 > c0020840: 1a1a151a .word 0x1a1a151a > c0020844: 1a1a131a .word 0x1a1a131a > c0020848: 081a .short 0x081a > c002084a: 2200 movs r2, #0 > c002084c: 4b08 ldr r3, [pc, #32] ; (c0020870 > <vcpu_reg+0x4c>) > c002084e: eb01 1102 add.w r1, r1, r2, lsl #4 > c0020852: 3090 adds r0, #144 ; 0x90 > c0020854: f853 3021 ldr.w r3, [r3, r1, lsl #2] > c0020858: eb00 0083 add.w r0, r0, r3, lsl #2 > c002085c: bc10 pop {r4} > c002085e: 4770 bx lr > c0020860: 2205 movs r2, #5 > c0020862: e7f3 b.n c002084c <vcpu_reg+0x28> > c0020864: 2204 movs r2, #4 > c0020866: e7f1 b.n c002084c <vcpu_reg+0x28> > c0020868: f022 0210 bic.w r2, r2, #16 > c002086c: e7ee b.n c002084c <vcpu_reg+0x28> > c002086e: de02 .short 0xde02 > c0020870: c027b358 .word 0xc027b358 > > So I was actually lying through my teeth: There *is* a table lookup, > using the lovely TBB instruction. And just for that, this patch deserves > to be merged : the table is smaller and the code more readable. What > else do you want? ;-) > the code is definitely more readable, and I was definitely going to merge it, and now even more so. I guess my question was education for the both of us;) _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm