Hi, sh.c:expand_cbranchdi4 forgot to produce the code for comparing high 32-bit parts when the second operand is a constant of which high 32-bit part is zero. The attached patch is to fix it and adds a new test for this PR. Tested sh4-unknown-linux-gnu and i686-pc-linux-gnu with no new regressions. Applied on trunk.
I'll backport this to the release branches because the issue is a regression on all release branches from 4.2. Regards, kaz -- 2011-05-30 Kaz Kojima <kkoj...@gcc.gnu.org> PR target/49186 * config/sh/sh.c (expand_cbranchdi4): Set msw_skip when the high part of the second operand is 0. [testsuite] PR target/49186 * gcc.c-torture/execute/pr49186.c: New. diff -uprN ORIG/trunk/gcc/config/sh/sh.c trunk/gcc/config/sh/sh.c --- ORIG/trunk/gcc/config/sh/sh.c 2011-05-27 14:51:19.000000000 +0900 +++ trunk/gcc/config/sh/sh.c 2011-05-27 19:28:06.000000000 +0900 @@ -2143,7 +2143,10 @@ expand_cbranchdi4 (rtx *operands, enum r else if (op2h != CONST0_RTX (SImode)) msw_taken = LTU; else - break; + { + msw_skip = swap_condition (LTU); + break; + } msw_skip = swap_condition (msw_taken); } break; diff -uprN ORIG/trunk/gcc/testsuite/gcc.c-torture/execute/pr49186.c trunk/gcc/testsuite/gcc.c-torture/execute/pr49186.c --- ORIG/trunk/gcc/testsuite/gcc.c-torture/execute/pr49186.c 1970-01-01 09:00:00.000000000 +0900 +++ trunk/gcc/testsuite/gcc.c-torture/execute/pr49186.c 2011-05-29 22:32:08.000000000 +0900 @@ -0,0 +1,15 @@ +/* PR target/49186 */ +extern void abort (void); + +int +main () +{ + int x; + unsigned long long uv = 0x1000000001ULL; + + x = (uv < 0x80) ? 1 : ((uv < 0x800) ? 2 : 3); + if (x != 3) + abort (); + + return 0; +}