(('bcsel', ('ine', 'a@32', 0), ('iadd', 31, ('ineg', ('ufind_msb_rev', a))), ('ufind_msb_rev', a)), ('ufind_msb', a), '!options->lower_find_msb_to_reverse'),
(('bcsel', ('ieq', 'a@32', 0), ('ufind_msb_rev', a), ('iadd', 31, ('ineg', ('ufind_msb_rev', a)))), ('ufind_msb', a), '!options->lower_find_msb_to_reverse'),
+ # This is safe. Both ufind_msb_rev and bitfield_reverse can only have
+ # 32-bit sources, so the transformation can only generate correct NIR.
(('find_lsb', ('bitfield_reverse', a)), ('ufind_msb_rev', a), 'options->has_find_msb_rev'),
(('ufind_msb_rev', ('bitfield_reverse', a)), ('find_lsb', a), '!options->lower_find_lsb'),
(('uclz', a), ('umin', 32, ('ufind_msb_rev', a)), 'options->lower_uclz'),
- (('find_lsb', 'value'),
+ (('find_lsb', 'value@64'),
('ufind_msb', ('iand', 'value', ('ineg', 'value'))),
'options->lower_find_lsb'),
+ (('find_lsb', 'value'),
+ ('ufind_msb', ('u2u32', ('iand', 'value', ('ineg', 'value')))),
+ 'options->lower_find_lsb'),
+
(('extract_i8', a, 'b@32'),
('ishr', ('ishl', a, ('imul', ('isub', 3, b), 8)), 24),
'options->lower_extract_byte'),