This is an archive of the discontinued LLVM Phabricator instance.

[X86] Remove masking from pternlog llvm intrinsics and use a select instruction instead.
ClosedPublic

Authored by craig.topper on May 20 2018, 10:36 PM.

Details

Summary

Because the intrinsics in the headers are implemented as macros, we can't just use a select builtin and pternlog builtin. This would require one of the macro arguments to be used twice. Depending on what was passed to the macro we could expand an expression twice leading to weird behavior. We could maybe declare our local variable in the macro, but that would need to worry about name collisions.

To avoid that just generate IR directly in CGBuiltin.cpp.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.May 20 2018, 10:36 PM

So do these really need to be implemented as macros?

Because the builtins take one of the arguments as an immediate, they must be implemented as macros. This was the frontend can verify that it's an imediate or a constant expression.

RKSimon accepted this revision.May 21 2018, 10:01 AM

LGTM - I'd love to see constexpr arguments someday in C/C++ to avoid all of these macro shenanigans.......

This revision is now accepted and ready to land.May 21 2018, 10:01 AM
This revision was automatically updated to reflect the committed changes.