On 2/3/22 16:18, Jakub Jelinek wrote:
On Thu, Feb 03, 2022 at 04:04:57PM -0500, Jason Merrill wrote:
I think it would be clearer to leave the !DECL_P case alone and add
/* In C++ it is unspecified, and so non-constant, whether two
equivalent strings have the same address. */
else if (folding_cxx_constexpr
&& (TREE_CODE (base0) == STRING_CST
|| TREE_CODE (base1) == STRING_CST)
The point was to let the first if handle for
!folding_cxx_constexpr the cases with STRING_CST
as one or both operands and if that falls through, return 2.
Ah, I see. And then for folding_cxx_constexpr you have your new code toward
the bottom of the function that can say they're unequal in some cases. Can
you combine the STRING_CST handling for both values of folding_cxx_constexpr
instead of having them so far apart?
Not easily, because for the folding_cxx_constexpr case it primarily reuses
the code from the last else if - computing sizes of objects and checking
if one is at a start of one and another at the end of the other.
And the !folding_cxx_constexpr case shouldn't also use that code?
One further option would be to compute early flags like
enum { OFF_POS_START, OFF_POS_MIDDLE, OFF_POS_END } pos0, pos1;
and then just use them or ignore them in the decisions later.
If that helps to refactor a bit, sure.
Jason