diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 60079157d09..5e795cee8fa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2003-01-20 Kazu Hirata + + * config/h8300/h8300.c (notice_update_cc): Don't assume that + recog_data.operands[0] is always associated with cc0. + 2003-01-19 David Edelsohn * collect2.c (ldgetname): Expand declaration to prototype. diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index c98f6e11d6b..faa924816ed 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -1710,6 +1710,8 @@ notice_update_cc (body, insn) rtx body; rtx insn; { + rtx set; + switch (get_attr_cc (insn)) { case CC_NONE: @@ -1732,7 +1734,10 @@ notice_update_cc (body, insn) that's ok because alter_cond will change tests to use EQ/NE. */ CC_STATUS_INIT; cc_status.flags |= CC_OVERFLOW_UNUSABLE | CC_NO_CARRY; - cc_status.value1 = recog_data.operand[0]; + set = single_set (insn); + cc_status.value1 = SET_SRC (set); + if (SET_DEST (set) != cc0_rtx) + cc_status.value2 = SET_DEST (set); break; case CC_SET_ZNV: @@ -1741,9 +1746,10 @@ notice_update_cc (body, insn) alter_cond will change tests to use EQ/NE. */ CC_STATUS_INIT; cc_status.flags |= CC_NO_CARRY; - cc_status.value1 = recog_data.operand[0]; - if (GET_CODE (body) == SET && REG_P (SET_SRC (body))) - cc_status.value2 = SET_SRC (body); + set = single_set (insn); + cc_status.value1 = SET_SRC (set); + if (SET_DEST (set) != cc0_rtx) + cc_status.value2 = SET_DEST (set); break; case CC_COMPARE: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 71f07f722a6..79e76c02697 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-01-20 Kazu Hirata + + * gcc.c-torture/execute/20030120-1.c: New. + 2003-01-19 Paolo Carlini * g++.old-deja/g++.pt/typename13.C: Remove XFAIL. diff --git a/gcc/testsuite/gcc.c-torture/execute/20030120-1.c b/gcc/testsuite/gcc.c-torture/execute/20030120-1.c new file mode 100644 index 00000000000..0ac0ecf7025 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20030120-1.c @@ -0,0 +1,50 @@ +/* On H8/300 port, NOTICE_UPDATE_CC had a bug that causes the final + pass to remove test insns that should be kept. */ + +unsigned short +test1 (unsigned short w) +{ + if ((w & 0xff00) == 0) + { + if (w == 0) + w = 2; + } + return w; +} + +unsigned long +test2 (unsigned long w) +{ + if ((w & 0xffff0000) == 0) + { + if (w == 0) + w = 2; + } + return w; +} + +int +test3 (unsigned short a) +{ + if (a & 1) + return 1; + else if (a) + return 1; + else + return 0; +} + +int +main () +{ + if (test1 (1) != 1) + abort (); + + if (test2 (1) != 1) + abort (); + + if (test3 (2) != 1) + abort (); + + exit (0); +}