On Wed, Dec 14, 2016 at 4:33 PM, Jakub Jelinek <ja...@redhat.com> wrote: > On Wed, Dec 14, 2016 at 04:30:39PM +0100, Uros Bizjak wrote: >> Apparently, Qt source uses these two builtins. As the removal brings >> much pain, I'd like to commit the following patch to restore >> __builtin_clzs and __builtin_ctzs on gcc-6 branch. >> >> 2016-12-14 Uros Bizjak <ubiz...@gmail.com> >> >> PR target/59874 >> * config/i386/i386.c (enum ix86_builtins): Add IX86_BUILTIN_CLZS >> and IX86_BUILTIN_CTZS. >> (bdesc_args): Add __builtin_clzs and __builtin_ctzs. >> (ix86_fold_builtin): Handle IX86_BUILTIN_CTZS and IX86_BUILTIN_CLZS. >> >> Bootstrapped and regression tested on x86_64-linux-gnu. > > Ok for 6. For 7 we ask them to change it to the new builtins?
I'm investigating automatic conversion to HImode insn, something along the lines: +(define_insn_and_split "*ctzhi2" + [(set (match_operand:SI 0 "register_operand") + (ctz:SI + (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand")))) + (clobber (reg:CC FLAGS_REG))] + "TARGET_BMI + && can_create_pseudo_p ()" + "#" + "&& 1" + [(const_int 0)] +{ + rtx tmp = gen_reg_rtx (HImode); + + emit_insn (gen_bmi_tzcnt_hi (tmp, operands[1])); + emit_insn (gen_zero_extendhisi2 (operands[0], tmp)); + DONE; +}) But it looks that __builtin_clzs and __builtin_ctzs will also have to stay. Uros.