This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH,SH] 64-bit integer comparison is incorrect
- From: Christian BRUEL <christian dot bruel at st dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- Date: Tue, 15 Apr 2008 16:31:59 +0200
- Subject: [PATCH,SH] 64-bit integer comparison is incorrect
Hello,
The attached tiny patch fixes a bug impacting long long integer
comparisons when a comparison is split into 3 expand_cbranchsi4, whereas
the first one modifies the operands. Consequenlty the 'msw_skip' test
that was not modified is becoming wrong.
This is easely exibited with a small test in -O0 as in:
int main (void)
{
long long int n = -1LL;
if (n < -2LL)
{
return 0;
}
return 1;
}
I added a test to the testsuite catching more cases.
The testsuite is still running. If the patch is ok I'll commit after the
results are available.
Best Regards
Christian
2008-04-14 Christian Bruel <christian.bruel@st.com>
* config/sh/sh.c (expand_cbranchdi4): Use original operands for
msw_skip comparison.
2008-04-14 Christian Bruel <christian.bruel@st.com>
* gcc.dg/dicomp.c: New Testcase.
Index: gcc/config/sh/sh.c
===================================================================
--- gcc/config/sh/sh.c (revision 134313)
+++ gcc/config/sh/sh.c (working copy)
@@ -1685,6 +1685,14 @@
{
rtx taken_label = operands[3];
+ /* Operands were possibly modified, but msw_skip doesn't expect this.
+ Always use the original ones. */
+ if (msw_taken != CODE_FOR_nothing)
+ {
+ operands[1] = op1h;
+ operands[2] = op2h;
+ }
+
operands[3] = skip_label = gen_label_rtx ();
expand_cbranchsi4 (operands, msw_skip, msw_skip_prob);
operands[3] = taken_label;