From: Martin Liska Date: Mon, 18 Nov 2019 11:51:05 +0000 (+0100) Subject: Verify NOP_EXPR LHS type in IPA ICF. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=446096148ca9775cb56f9ee924fa283babcd0b76;p=gcc.git Verify NOP_EXPR LHS type in IPA ICF. 2019-11-18 Martin Liska PR ipa/92529 * ipa-icf-gimple.c (func_checker::compare_gimple_assign): Compare LHS types of NOP_EXPR. 2019-11-18 Martin Liska PR ipa/92529 * gcc.dg/ipa/pr92529.c: New test. From-SVN: r278395 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 78a918281a7..a829a68f543 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-11-18 Martin Liska + + PR ipa/92529 + * ipa-icf-gimple.c (func_checker::compare_gimple_assign): + Compare LHS types of NOP_EXPR. + 2019-11-18 Matthew Malcomson * run-rtl-passes.c (run_rtl_passes): Accept and handle empty diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c index ac53a1dfbbf..9aa2fe00138 100644 --- a/gcc/ipa-icf-gimple.c +++ b/gcc/ipa-icf-gimple.c @@ -620,6 +620,13 @@ func_checker::compare_gimple_assign (gimple *s1, gimple *s2) arg1 = gimple_op (s1, i); arg2 = gimple_op (s2, i); + /* LHS types of NOP_EXPR must be compatible. */ + if (CONVERT_EXPR_CODE_P (code1) && i == 0) + { + if (!compatible_types_p (TREE_TYPE (arg1), TREE_TYPE (arg2))) + return return_false_with_msg ("GIMPLE NOP LHS type mismatch"); + } + if (!compare_operand (arg1, arg2)) return return_false_with_msg ("GIMPLE assignment operands " "are different"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 87705b421fc..8773d5073e8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-18 Martin Liska + + PR ipa/92529 + * gcc.dg/ipa/pr92529.c: New test. + 2019-11-18 Matthew Malcomson * gcc.dg/rtl/aarch64/unspecified-pass-error.c: New test. diff --git a/gcc/testsuite/gcc.dg/ipa/pr92529.c b/gcc/testsuite/gcc.dg/ipa/pr92529.c new file mode 100644 index 00000000000..0864f342773 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr92529.c @@ -0,0 +1,28 @@ +/* PR ipa/92529 */ +/* { dg-options "-O2 -fdump-ipa-icf-optimized" } */ + +int +foo(volatile int a) +{ + return (char)a; +} + +int +bar(volatile int a) +{ + return (short)a; +} + +#pragma GCC optimize ("-O0") + +int main(int argc, char **argv) +{ + int r = bar(1000); + __builtin_printf ("global: %d\n", r); + if (r != 1000) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */