From: ktkachov Date: Wed, 16 Dec 2015 10:01:48 +0000 (+0000) Subject: [ARM] PR target/68648: Fold NOT of CONST_INT in andsi_iorsi3_notsi splitter X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=054fd237e4058578d592319d2f0b9063032fed81;p=thirdparty%2Fgcc.git [ARM] PR target/68648: Fold NOT of CONST_INT in andsi_iorsi3_notsi splitter PR target/68648 * config/arm/arm.md (*andsi_iorsi3_notsi): Try to simplify the complement of operands[3] during splitting. * gcc.c-torture/execute/pr68648.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231675 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6450d52b0c2c..464558f51e47 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-12-16 Kyrylo Tkachov + + PR target/68648 + * config/arm/arm.md (*andsi_iorsi3_notsi): Try to simplify + the complement of operands[3] during splitting. + 2015-12-16 Richard Biener PR tree-optimization/68892 diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index a91873c8948b..26833613edf4 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -3228,8 +3228,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 7a3c5e469957..d90d43c920fd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-12-16 Kyrylo Tkachov + + PR target/68648 + * gcc.c-torture/execute/pr68648.c: New test. + 2015-12-16 Richard Biener PR tree-optimization/68892 diff --git a/gcc/testsuite/gcc.c-torture/execute/pr68648.c b/gcc/testsuite/gcc.c-torture/execute/pr68648.c new file mode 100644 index 000000000000..fc66806a99a0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr68648.c @@ -0,0 +1,20 @@ +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 (); +}