> The second vfirst won't be redundant. It'll be removed by CSE in RTL. > That's how it works for Adv. SIMD as well. Both the compare and the > extract code redo the same computation using addhn, and the one in > the exit is removed because it's the exact same one as in the loop. > > So as long as your RTL reflects that the operations are the same ( > which they should be as they operate on the same inputs and len) then > the second vfirst should be removed leaving you with the optimal case > no?
Right, I guess with a bit of combine magic and CSE we could turn idx = vfirst idx = idx != -1 branch idx = vfirst ... into the optimal sequence. So yea, I think I'll just go ahead with it, I'll be busy with the peeling issue still anyway and getting something in is my main priority. All we need is a proper new IFN for it which is not called IFN_COMPRESS. IFN_ANY_ACTIVE? IFN_...? I suppose your idea is for this new IFN to abstract away what every target does and keep the rest mostly the same? Or would the discriminator be IFN_... + vec_cbranch availability? The live-operation changes would be smaller, just that we'd still need the bit of can_vec_var_idx etc. plumbing (as we'd materialize the index from the mask on the fly so to say). (That said, I still don't find the previous approach too bad, all things considered, as it wouldn't rely on CSE and combine and if we query the insn's "preferred" value at 0 we could also clearly distinguish: If -1 and no vec_cbranch is supported -> index based, else mask based.) -- Regards Robin
