<html><head><base href="x-msg://6/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Oct 1, 2011, at 2:42 AM, Jonas Paulsson wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Menlo; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; "><div dir="ltr"><div dir="ltr">I understand the idea behind compare_numeric() is to compare strings containing digits in a special way: Do a normal string-compare up to the point where both string elemnts are numerical. Find then an outcome based on the number of consecutive digits in the strings while disregarding the value of the digits, eg a12b < a123.<br></div></div></div></span></blockquote><div><br></div><div>Almost. It is trying to compare embedded sequences of digits as numbers. It does this by first comparing the length of the digit sequence, and then a lexicographical comparison of equal length digit sequences.</div><br><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Menlo; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; "><div dir="ltr"><div dir="ltr">I guess then this order should hold: a12 == a22 < a1b, for these strings.<br></div></div></div></span></blockquote><div><br></div><div>No, a1b < a12 < a22. "a1b" is smaller than "a12" because it has fewer digits. "a12" has the same number of digits as "a22", but it is lexicographically smaller.</div><div><br></div><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class="hmmessage"><div dir="ltr"><div dir="ltr"><font class="Apple-style-span" face="Tahoma" size="3">Looking at StringRef::compare_numeric(StringRef RHS), the problem is, for a12 and a1b, Data[1]==RHS.Data[1], and the continue is reached.  Data[2] is then less than RHS.Data[2], so a12 < a1b. But in the case for a22 and a1b, we get the opposite, since '2'!='1', and 22 is more digits than 1. So we get a12 < a1b < a22, which is incorrect, because a12==a22.</font><br><br><font class="Apple-style-span" face="Tahoma" size="3">My problem was with these registers: a23g, a2g and a3g. When I renamed a23g to aa23g, it worked. Since '2'=='2', the problem was that a23g<a2g.</font><br><br><font class="Apple-style-span" face="Tahoma" size="3">I think the fix is to first check for two digits, and move the equality comparison to after this. Then a2g < a3g < a23g:</font><br></div></div></div></span></blockquote><br><blockquote type="cite"><span class="Apple-style-span" style="font-family: Tahoma; ">/lib/Support/StringRef.cpp:</span><span class="Apple-style-span" style="border-collapse: separate; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class="hmmessage"><div dir="ltr"><div dir="ltr"><font class="Apple-style-span" face="Tahoma" size="3">48a49,50</font><br><font class="Apple-style-span" face="Tahoma" size="3">>     if (Data[I] == RHS.Data[I])</font><br><font class="Apple-style-span" face="Tahoma" size="3">>       continue;</font><br><font class="Apple-style-span" face="Tahoma" size="3">61,62d62</font><br><font class="Apple-style-span" face="Tahoma" size="3"><     if (Data[I] == RHS.Data[I])</font><br><font class="Apple-style-span" face="Tahoma" size="3"><       continue;</font><br><br><font class="Apple-style-span" face="Tahoma" size="3">I ran this, and now I have no problems, and the other targets built as well, at least, without problems. I have not run the testsuite.</font><br></div></div></div></span></blockquote><div><br></div><div>Your fix is correct, but there is one problem: The algorithm is now quadratic in the length of embedded digit sequences.</div><div><br></div><div>This is easy to fix, see r140859.</div><div><br></div><div>Thanks!</div><div><br></div><div>/jakob</div><div><br></div></div></body></html>