From: Jakub Jelinek Date: Fri, 1 Apr 2016 16:08:21 +0000 (+0200) Subject: re PR rtl-optimization/70467 (Useless "and [esp],-1" emitted on AND with uint64_t... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=763cd859a1d87f361a88e380e849cf6f0eb10751;p=gcc.git re PR rtl-optimization/70467 (Useless "and [esp],-1" emitted on AND with uint64_t variable) PR rtl-optimization/70467 * config/i386/i386.md (*add3_doubleword, *sub3_doubleword): If low word of the last operand is 0, just emit addition/subtraction for the high word. * gcc.target/i386/pr70467-2.c: New test. From-SVN: r234679 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index de3b8c57543..81d88797472 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-04-01 Jakub Jelinek + + PR rtl-optimization/70467 + * config/i386/i386.md (*add3_doubleword, *sub3_doubleword): + If low word of the last operand is 0, just emit addition/subtraction + for the high word. + 2016-04-01 Andreas Krebbel PR target/70404 diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index f324ea7ea41..09da69e7e44 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -5449,7 +5449,14 @@ (match_dup 4)) (match_dup 5))) (clobber (reg:CC FLAGS_REG))])] - "split_double_mode (mode, &operands[0], 3, &operands[0], &operands[3]);") +{ + split_double_mode (mode, &operands[0], 3, &operands[0], &operands[3]); + if (operands[2] == const0_rtx) + { + ix86_expand_binary_operator (PLUS, mode, &operands[3]); + DONE; + } +}) (define_insn "*add_1" [(set (match_operand:SWI48 0 "nonimmediate_operand" "=r,rm,r,r") @@ -6379,7 +6386,14 @@ (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0))) (match_dup 5))) (clobber (reg:CC FLAGS_REG))])] - "split_double_mode (mode, &operands[0], 3, &operands[0], &operands[3]);") +{ + split_double_mode (mode, &operands[0], 3, &operands[0], &operands[3]); + if (operands[2] == const0_rtx) + { + ix86_expand_binary_operator (MINUS, mode, &operands[3]); + DONE; + } +}) (define_insn "*sub_1" [(set (match_operand:SWI 0 "nonimmediate_operand" "=m,") diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a4a1df51afc..e908caaf4d1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-04-01 Jakub Jelinek + + PR rtl-optimization/70467 + * gcc.target/i386/pr70467-2.c: New test. + 2016-04-01 Jakub Jelinek Marek Polacek diff --git a/gcc/testsuite/gcc.target/i386/pr70467-2.c b/gcc/testsuite/gcc.target/i386/pr70467-2.c new file mode 100644 index 00000000000..4c1715c87e5 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr70467-2.c @@ -0,0 +1,20 @@ +/* PR rtl-optimization/70467 */ +/* { dg-do compile { target ia32 } } */ +/* { dg-options "-O2" } */ + +unsigned long long +foo (unsigned long long x) +{ + return x + 0x12345600000000ULL; +} + +unsigned long long +bar (unsigned long long x) +{ + return x - 0x12345600000000ULL; +} + +/* { dg-final { scan-assembler-not "addl\[ \t\]*.0," } } */ +/* { dg-final { scan-assembler-not "subl\[ \t\]*.0," } } */ +/* { dg-final { scan-assembler-not "adcl\[^\n\r\]*%" } } */ +/* { dg-final { scan-assembler-not "sbbl\[^\n\r\]*%" } } */