Hi, Consider the attached testcase.
Working on a private port (Infact I see this problem on arm-none-eabi-gcc too). I see the following in test.c.003t.original fail = (short int) usi <= ssi; And then in test.c.025t.ssa usi.2_5 = (short int) usi_4; fail.3_6 = usi.2_5 <= ssi_2; Now ccp1 does constant propagation and we are left with usi.2_5 = -256; This causes the test to fail. Clearly the problem seems to be that since usi is unsigned short int a short int cant represent all the possible values of usi I reverted the following patch and the test passed. PR middle-end/35163 * fold-const.c (fold_widened_comparison): Use get_unwidened in value-preserving mode. Disallow final truncation. Now with the patch reverted, test.c.003t.original has fail = (int) ssi >= (int) usi; And this problem vanished. Am I missing something here ? Thanks, Pranav
int fail; short fs2(void) { return 126; } unsigned short ufs1(void) { return 65280; } int main () { short ssi; unsigned short usi; ssi = fs2(); usi = ufs1(); fail = !(ssi < usi); if (fail) printf ("Failed\n"); else printf ("Successful\n"); return 0; }