https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103565
Bug ID: 103565
Summary: GCC emits more assembly than clang for carry flag
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: unlvsur at live dot com
Target Milestone: ---
I tried both examples. One emulation with the pattern. Another is with the x86
intrinsic. GCC emits more instructions than clang.
https://godbolt.org/z/d15WEY85T
https://godbolt.org/z/cob36P8nz
Also can GCC be able to understand the pattern of add_carry_pattern just like
it understands std::rotl?
https://github.com/gcc-mirror/gcc/blob/8d4ef2299cbf9517877dab60d48f34835758a6ee/libstdc%2B%2B-v3/include/std/bit#L135
template<typename T>
inline constexpr bool add_carry_pattern(bool carry,T a,T b,T& out) noexcept
{
T temp{carry+a};
out=temp+b;
return (out < b) | (temp < a);
}
So we do not need that intrinsic anymore and the whole thing can be optimized
at SSA level, rather than RTL level??