I was just curious if this had been noticed and it was decided if bset promotion by default was worth it anyways as this is a small test case. I’ll look into a fix. I’m not sure how it would affect tests people might be running if we simply removed this and handled bset opts differently.
I really wish we’d gotten a bsetw instruction. The current hack works well when there is no mask on the shift amount and the upper bits of the result aren’t used by later instructions. If we let it become RISCVISD::SLLW we can’t turn it into BSET without adding an andi and a sext.w.
Maybe we can write an isel pattern for (sext (shl 1, (and X, 31))) and use sllw (li 1), X in that case.