From 30b318bfa187140eafce94794a8091163f7e4eb5 Mon Sep 17 00:00:00 2001 From: Kyrylo Tkachov Date: Thu, 14 Jan 2016 17:27:42 +0000 Subject: [PATCH] [ARM][4.9 backport] Fix PR target/68648 PR target/68648 * config/arm/arm.md (*andsi_iorsi3_notsi): Try to simplify the complement of operands[3] during splitting. * gcc.dg/torture/pr68648.c: New test. From-SVN: r232375 --- gcc/ChangeLog | 6 ++++++ gcc/config/arm/arm.md | 18 ++++++++++++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr68648.c | 23 +++++++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr68648.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 305392cacc2d..a69e93799ddc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-01-14 Kyrylo Tkachov + + PR target/68648 + * config/arm/arm.md (*andsi_iorsi3_notsi): Try to simplify + the complement of operands[3] during splitting. + 2016-01-12 Jeff Law PR target/63347 diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 3bb8aef36f7e..138d17e8d7de 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -3331,8 +3331,22 @@ "#" ; "orr%?\\t%0, %1, %2\;bic%?\\t%0, %0, %3" "&& reload_completed" [(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 2))) - (set (match_dup 0) (and:SI (not:SI (match_dup 3)) (match_dup 0)))] - "" + (set (match_dup 0) (and:SI (match_dup 4) (match_dup 5)))] + { + /* If operands[3] is a constant make sure to fold the NOT into it + to avoid creating a NOT of a CONST_INT. */ + rtx not_rtx = simplify_gen_unary (NOT, SImode, operands[3], SImode); + if (CONST_INT_P (not_rtx)) + { + operands[4] = operands[0]; + operands[5] = not_rtx; + } + else + { + operands[5] = operands[0]; + operands[4] = not_rtx; + } + } [(set_attr "length" "8") (set_attr "ce_count" "2") (set_attr "predicable" "yes") diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c6fb9be79512..36e67994c538 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-01-14 Kyrylo Tkachov + + PR target/68648 + * gcc.dg/torture/pr68648.c: New test. + 2016-01-12 Jeff Law PR target/63347 diff --git a/gcc/testsuite/gcc.dg/torture/pr68648.c b/gcc/testsuite/gcc.dg/torture/pr68648.c new file mode 100644 index 000000000000..762eb8243bd7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr68648.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" } */ + +int __attribute__ ((noinline)) +foo (void) +{ + return 123; +} + +int __attribute__ ((noinline)) +bar (void) +{ + int c = 1; + c |= 4294967295 ^ (foo () | 4073709551608); + return c; +} + +int +main () +{ + if (bar () != 0x83fd4005) + __builtin_abort (); +} -- 2.47.2