[PATCH] Also fold bmi/bmi2/tbm bextr/bextri/bzhi/pext/pdep builtins

Uros Bizjak ubizjak@gmail.com
Sat Oct 22 11:46:00 GMT 2016

On Fri, Oct 21, 2016 at 5:37 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Fri, Oct 21, 2016 at 5:26 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>> This patch on top of the just posted patch adds folding for a couple more
>> builtins (though, hundreds or thousands of other md builtins remain unfolded
>> even though they actually could be folded for e.g. const arguments).

Just a few words regarding other unfolded builtins. x86 intrinsics
(and consequently builtins) are considered as a convenient way to emit
assembly instructions. So, the same rules as when writting assembly,
although slightly relaxed, should apply there. IMO, compiler
optimizations with intrinsics should be an exception, not the rule. As
an example, __builtin_ctz, __builtin_clz and functionaly similar
target-builtins are rather messy w.r.t to "undefinedness", so I think
this fact warrants some help from the compiler. But there is no need
to handle every single builtin - only a competent person that knows
the background of these intrinsics should use them.


More information about the Gcc-patches mailing list