From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1005) id 98001385773E; Tue, 9 May 2023 20:33:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98001385773E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683664416; bh=08v8YAfa+1XvxOE17sM2ClZMUC/Eu2V39P+MTnO+jTw=; h=From:To:Subject:Date:From; b=L52NlR5V1aXvtuDq1QNSK5tiArdnbLX5Et1B3hz3IIjH2DnVw37IRNgGBOHJZ0/Oq 0lfEvqc5C0oPJu/Cf7PfFMcM/09iIt8O3cIie+P69XpRUNDKVnkNJD3JADihrkuFny 7Yo3Efp58MStUL6HpHaxFvedAFOOUb12aFKrr+iU= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Michael Meissner To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/meissner/heads/work121)] Revert patches X-Act-Checkin: gcc X-Git-Author: Michael Meissner X-Git-Refname: refs/users/meissner/heads/work121 X-Git-Oldrev: 8b6710291e89562b729388da8b0838668516c636 X-Git-Newrev: 32fb74a03a34d8c481ccc5713ca328862ff2840b Message-Id: <20230509203336.98001385773E@sourceware.org> Date: Tue, 9 May 2023 20:33:36 +0000 (GMT) List-Id: https://gcc.gnu.org/g:32fb74a03a34d8c481ccc5713ca328862ff2840b commit 32fb74a03a34d8c481ccc5713ca328862ff2840b Author: Michael Meissner Date: Tue May 9 16:33:33 2023 -0400 Revert patches Diff: --- gcc/config/rs6000/fusion.md | 17 +- gcc/config/rs6000/genfusion.pl | 260 ++++++++------------- gcc/testsuite/g++.target/powerpc/pr105325.C | 26 --- .../gcc.target/powerpc/fusion-p10-ldcmpi.c | 4 +- 4 files changed, 100 insertions(+), 207 deletions(-) diff --git a/gcc/config/rs6000/fusion.md b/gcc/config/rs6000/fusion.md index da9953d9ad9..d45fb138a70 100644 --- a/gcc/config/rs6000/fusion.md +++ b/gcc/config/rs6000/fusion.md @@ -22,7 +22,7 @@ ;; load mode is DI result mode is clobber compare mode is CC extend is none (define_insn_and_split "*ld_cmpdi_cr0_DI_clobber_CC_none" [(set (match_operand:CC 2 "cc_reg_operand" "=x") - (compare:CC (match_operand:DI 1 "ds_form_mem_operand" "YZ") + (compare:CC (match_operand:DI 1 "ds_form_mem_operand" "m") (match_operand:DI 3 "const_m1_to_1_operand" "n"))) (clobber (match_scratch:DI 0 "=r"))] "(TARGET_P10_FUSION)" @@ -43,7 +43,7 @@ ;; load mode is DI result mode is clobber compare mode is CCUNS extend is none (define_insn_and_split "*ld_cmpldi_cr0_DI_clobber_CCUNS_none" [(set (match_operand:CCUNS 2 "cc_reg_operand" "=x") - (compare:CCUNS (match_operand:DI 1 "ds_form_mem_operand" "YZ") + (compare:CCUNS (match_operand:DI 1 "ds_form_mem_operand" "m") (match_operand:DI 3 "const_0_to_1_operand" "n"))) (clobber (match_scratch:DI 0 "=r"))] "(TARGET_P10_FUSION)" @@ -64,7 +64,7 @@ ;; load mode is DI result mode is DI compare mode is CC extend is none (define_insn_and_split "*ld_cmpdi_cr0_DI_DI_CC_none" [(set (match_operand:CC 2 "cc_reg_operand" "=x") - (compare:CC (match_operand:DI 1 "ds_form_mem_operand" "YZ") + (compare:CC (match_operand:DI 1 "ds_form_mem_operand" "m") (match_operand:DI 3 "const_m1_to_1_operand" "n"))) (set (match_operand:DI 0 "gpc_reg_operand" "=r") (match_dup 1))] "(TARGET_P10_FUSION)" @@ -85,7 +85,7 @@ ;; load mode is DI result mode is DI compare mode is CCUNS extend is none (define_insn_and_split "*ld_cmpldi_cr0_DI_DI_CCUNS_none" [(set (match_operand:CCUNS 2 "cc_reg_operand" "=x") - (compare:CCUNS (match_operand:DI 1 "ds_form_mem_operand" "YZ") + (compare:CCUNS (match_operand:DI 1 "ds_form_mem_operand" "m") (match_operand:DI 3 "const_0_to_1_operand" "n"))) (set (match_operand:DI 0 "gpc_reg_operand" "=r") (match_dup 1))] "(TARGET_P10_FUSION)" @@ -106,7 +106,7 @@ ;; load mode is SI result mode is clobber compare mode is CC extend is none (define_insn_and_split "*lwa_cmpdi_cr0_SI_clobber_CC_none" [(set (match_operand:CC 2 "cc_reg_operand" "=x") - (compare:CC (match_operand:SI 1 "lwa_operand" "YZ") + (compare:CC (match_operand:SI 1 "ds_form_mem_operand" "m") (match_operand:SI 3 "const_m1_to_1_operand" "n"))) (clobber (match_scratch:SI 0 "=r"))] "(TARGET_P10_FUSION)" @@ -148,7 +148,7 @@ ;; load mode is SI result mode is SI compare mode is CC extend is none (define_insn_and_split "*lwa_cmpdi_cr0_SI_SI_CC_none" [(set (match_operand:CC 2 "cc_reg_operand" "=x") - (compare:CC (match_operand:SI 1 "lwa_operand" "YZ") + (compare:CC (match_operand:SI 1 "ds_form_mem_operand" "m") (match_operand:SI 3 "const_m1_to_1_operand" "n"))) (set (match_operand:SI 0 "gpc_reg_operand" "=r") (match_dup 1))] "(TARGET_P10_FUSION)" @@ -190,7 +190,7 @@ ;; load mode is SI result mode is EXTSI compare mode is CC extend is sign (define_insn_and_split "*lwa_cmpdi_cr0_SI_EXTSI_CC_sign" [(set (match_operand:CC 2 "cc_reg_operand" "=x") - (compare:CC (match_operand:SI 1 "lwa_operand" "YZ") + (compare:CC (match_operand:SI 1 "ds_form_mem_operand" "m") (match_operand:SI 3 "const_m1_to_1_operand" "n"))) (set (match_operand:EXTSI 0 "gpc_reg_operand" "=r") (sign_extend:EXTSI (match_dup 1)))] "(TARGET_P10_FUSION)" @@ -205,7 +205,6 @@ "" [(set_attr "type" "fused_load_cmpi") (set_attr "cost" "8") - (set_attr "sign_extend" "yes") (set_attr "length" "8")]) ;; load-cmpi fusion pattern generated by gen_ld_cmpi_p10 @@ -248,7 +247,6 @@ "" [(set_attr "type" "fused_load_cmpi") (set_attr "cost" "8") - (set_attr "sign_extend" "yes") (set_attr "length" "8")]) ;; load-cmpi fusion pattern generated by gen_ld_cmpi_p10 @@ -291,7 +289,6 @@ "" [(set_attr "type" "fused_load_cmpi") (set_attr "cost" "8") - (set_attr "sign_extend" "yes") (set_attr "length" "8")]) ;; load-cmpi fusion pattern generated by gen_ld_cmpi_p10 diff --git a/gcc/config/rs6000/genfusion.pl b/gcc/config/rs6000/genfusion.pl index 836dbd20948..e4db352e0ce 100755 --- a/gcc/config/rs6000/genfusion.pl +++ b/gcc/config/rs6000/genfusion.pl @@ -45,181 +45,103 @@ print <<'EOF'; EOF -# Print the insns for load and compare with -1/0/1. -# Arguments: -# lmode -- Integer mode ("DI", "SI", "HI", or "QI"). -# result -- "clobber", "GPR", or $lmode -# ccmode -- Sign vs. unsigned ("CC" or "CCUNS"). -# mem_format -- Memory format ("d" or "ds"). -# cmpl -- Suffix for compare ("l" or "") -# const_pred -- Predicate for constant (i.e. -1/0/1 or 0/1). -# extend -- "sign", "zero", or "none". -# echr -- Suffix for load ("a", "z", or ""). -# load -- Load instruction (i.e. "ld", "lwa", "lwz", etc.) -# np -- enum non_prefixed_form for memory type -# constraint -- constraint to use -# mem_pred -- predicate for the memory operation - -sub print_ld_cmpi_p10 +sub mode_to_ldst_char { - my ($lmode, $result, $ccmode, $cmpl, $const_pred, - $extend, $load, $np, $constraint, $mem_pred) = @_; - - # For clobber, we need a SI/DI reg in case we split because we have to - # sign/zero extend. - my $clobbermode = ($lmode =~ m/^[HQ]I$/) ? "GPR" : $lmode; - - # Break long print statements into smaller lines. - my $info = join (" ", - "load mode is ${lmode} result mode is ${result}", - "compare mode is ${ccmode} extend is ${extend}"); - - my $name = join ("", - "${load}_cmp${cmpl}di_cr0_${lmode}", - "_${result}_${ccmode}_${extend}"); - - my $cmp_op1 = "(match_operand:${lmode} 1 \"${mem_pred}\" \"${constraint}\")"; - - my $spaces = " " x (length ($ccmode) + 18); - - print ";; load-cmpi fusion pattern generated by gen_ld_cmpi_p10\n"; - print ";; ${info}\n"; - print "(define_insn_and_split \"*${name}\"\n"; - print " [(set (match_operand:${ccmode} 2 \"cc_reg_operand\" \"=x\")\n"; - print " (compare:${ccmode} ${cmp_op1}\n"; - print "${spaces}(match_operand:${lmode} 3 \"${const_pred}\" \"n\")))\n"; - - if ($result eq "clobber") - { - print " (clobber (match_scratch:${clobbermode} 0 \"=r\"))]\n"; - } - - else - { - my $load_op0 = "(match_operand:${result} 0 \"gpc_reg_operand\" \"=r\")"; - my $load_op1 = (($result eq $lmode) - ? "(match_dup 1)" - : "(${extend}_extend:${result} (match_dup 1))"); - print " (set ${load_op0} ${load_op1})]\n"; - } - - # Do not match prefixed loads. The machine only fuses non-prefixed loads - # with compare immediate. Take into account whether the load is a ds-form - # or a d-form instruction. - print " \"(TARGET_P10_FUSION)\"\n"; - print " \"${load}%X1 %0,%1\\;cmp${cmpl}di %2,%0,%3\"\n"; - print " \"&& reload_completed\n"; - print " && (cc_reg_not_cr0_operand (operands[2], CCmode)\n"; - print " || !address_is_non_pfx_d_or_x (XEXP (operands[1], 0),\n"; - print " ${lmode}mode, ${np}))\"\n"; - - if ($extend eq "none") - { - print " [(set (match_dup 0) (match_dup 1))\n"; - } - - else - { - my $resultmode = ($result eq "clobber") ? $clobbermode : $result; - print " [(set (match_dup 0) (${extend}_extend:${resultmode} (match_dup 1)))\n"; - } - - print " (set (match_dup 2)\n"; - print " (compare:${ccmode} (match_dup 0) (match_dup 3)))]\n"; - print " \"\"\n"; - print " [(set_attr \"type\" \"fused_load_cmpi\")\n"; - print " (set_attr \"cost\" \"8\")\n"; - - if ($extend eq "sign") - { - print " (set_attr \"sign_extend\" \"yes\")\n"; - } - - print " (set_attr \"length\" \"8\")])\n"; - print "\n"; + my ($mode) = @_; + my %x = (DI => 'd', SI => 'w', HI => 'h', QI => 'b'); + return $x{$mode} if exists $x{$mode}; + return '?'; } sub gen_ld_cmpi_p10 { - my ($lmode, $result, $mem_format, $extend); - - # Map mode to load instruction - my %signed_load = ("DI" => "ld", - "SI" => "lwa", - "HI" => "lha"); - - my %unsigned_load = ("DI" => "ld", - "SI" => "lwz", - "HI" => "lhz", - "QI" => "lbz"); - - # Memory predicate to use. For LWA, use the special LWA_OPERAND. - my %signed_memory_predicate = ("DI" => "ds_form_mem_operand", - "SI" => "lwa_operand", - "HI" => "non_update_memory_operand"); - - my %unsigned_memory_predicate = ("DI" => "ds_form_mem_operand", - "SI" => "non_update_memory_operand", - "HI" => "non_update_memory_operand", - "QI" => "non_update_memory_operand"); - - # Internal format of the memory instruction (enum non_prefixed_form) to use. - my %np = ("ds" => "NON_PREFIXED_DS", - "d" => "NON_PREFIXED_D"); - - # Constraint to use. - my %constraint = ("ds" => "YZ", - "d" => "m"); - - # Result modes to use. Clobber is used when you are comparing the load to - # -1/0/1, but you are not using it otherwise. EXTDI does not exist. We - # cannot directly use HI/QI results because we only have word and double word - # compared. For promotion, don't allow EXTQI because that would allow HI - # results which we can't do (use GPR instead). - my %result_modes = ("DI" => ["clobber", "DI"], - "SI" => ["clobber", "SI", "EXTSI" ], - "HI" => ["clobber", "EXTHI" ], - "QI" => ["clobber", "GPR" ]); - - foreach $lmode ("DI", "SI", "HI", "QI") - { - foreach $result (@{ $result_modes{$lmode} }) - { - # Handle CCmode (sign extended compares to -1, 0, or 1). We don't - # have a LBA instruction, so skip QImode. Both LD and LWA are - # DS-form instructions for signed loads. - if ($lmode ne "QI") - { - $mem_format = ($lmode =~ m/^[DS]I$/) ? "ds" : "d"; - $extend = (($lmode eq "DI" - || $lmode eq $result - || ($lmode eq "SI" && $result eq "clobber")) - ? "none" - : "sign"); - - print_ld_cmpi_p10 ($lmode, $result, "CC", "", - "const_m1_to_1_operand", $extend, - $signed_load{$lmode}, $np{$mem_format}, - $constraint{$mem_format}, - $signed_memory_predicate{$lmode}); - } - - # Handle CCUNS mode (zero extended compares to 0 or 1. - # LD is DS-form, but LWZ is not for unsigned loads. - $mem_format = ($lmode eq "DI") ? "ds" : "d"; - $extend = (($lmode eq "DI" - || $lmode eq $result - || ($lmode eq "SI" && $result eq "clobber")) - ? "none" - : "zero"); - - print_ld_cmpi_p10 ($lmode, $result, "CCUNS", "l", - "const_0_to_1_operand", $extend, - $unsigned_load{$lmode}, $np{$mem_format}, - $constraint{$mem_format}, - $unsigned_memory_predicate{$lmode}); - } + my ($lmode, $ldst, $clobbermode, $result, $cmpl, $echr, $constpred, + $mempred, $ccmode, $np, $extend, $resultmode); + LMODE: foreach $lmode ('DI','SI','HI','QI') { + $ldst = mode_to_ldst_char($lmode); + $clobbermode = $lmode; + # For clobber, we need a SI/DI reg in case we + # split because we have to sign/zero extend. + if ($lmode eq 'HI' || $lmode eq 'QI') { $clobbermode = "GPR"; } + RESULT: foreach $result ('clobber', $lmode, "EXT".$lmode) { + # EXTDI does not exist, and we cannot directly produce HI/QI results. + next RESULT if $result eq "EXTDI" || $result eq "HI" || $result eq "QI"; + # Don't allow EXTQI because that would allow HI result which we can't do. + $result = "GPR" if $result eq "EXTQI"; + CCMODE: foreach $ccmode ('CC','CCUNS') { + $np = "NON_PREFIXED_D"; + $mempred = "non_update_memory_operand"; + if ( $ccmode eq 'CC' ) { + next CCMODE if $lmode eq 'QI'; + if ( $lmode eq 'DI' || $lmode eq 'SI' ) { + # ld and lwa are both DS-FORM. + $np = "NON_PREFIXED_DS"; + $mempred = "ds_form_mem_operand"; + } + $cmpl = ""; + $echr = "a"; + $constpred = "const_m1_to_1_operand"; + } else { + if ( $lmode eq 'DI' ) { + # ld is DS-form, but lwz is not. + $np = "NON_PREFIXED_DS"; + $mempred = "ds_form_mem_operand"; + } + $cmpl = "l"; + $echr = "z"; + $constpred = "const_0_to_1_operand"; + } + if ($lmode eq 'DI') { $echr = ""; } + if ($result =~ m/^EXT/ || $result eq 'GPR' || $clobbermode eq 'GPR') { + # We always need extension if result > lmode. + if ( $ccmode eq 'CC' ) { + $extend = "sign"; + } else { + $extend = "zero"; + } + } else { + # Result of SI/DI does not need sign extension. + $extend = "none"; + } + print ";; load-cmpi fusion pattern generated by gen_ld_cmpi_p10\n"; + print ";; load mode is $lmode result mode is $result compare mode is $ccmode extend is $extend\n"; + + print "(define_insn_and_split \"*l${ldst}${echr}_cmp${cmpl}di_cr0_${lmode}_${result}_${ccmode}_${extend}\"\n"; + print " [(set (match_operand:${ccmode} 2 \"cc_reg_operand\" \"=x\")\n"; + print " (compare:${ccmode} (match_operand:${lmode} 1 \"${mempred}\" \"m\")\n"; + if ($ccmode eq 'CCUNS') { print " "; } + print " (match_operand:${lmode} 3 \"${constpred}\" \"n\")))\n"; + if ($result eq 'clobber') { + print " (clobber (match_scratch:${clobbermode} 0 \"=r\"))]\n"; + } elsif ($result eq $lmode) { + print " (set (match_operand:${result} 0 \"gpc_reg_operand\" \"=r\") (match_dup 1))]\n"; + } else { + print " (set (match_operand:${result} 0 \"gpc_reg_operand\" \"=r\") (${extend}_extend:${result} (match_dup 1)))]\n"; + } + print " \"(TARGET_P10_FUSION)\"\n"; + print " \"l${ldst}${echr}%X1 %0,%1\\;cmp${cmpl}di %2,%0,%3\"\n"; + print " \"&& reload_completed\n"; + print " && (cc_reg_not_cr0_operand (operands[2], CCmode)\n"; + print " || !address_is_non_pfx_d_or_x (XEXP (operands[1], 0),\n"; + print " ${lmode}mode, ${np}))\"\n"; + + if ($extend eq "none") { + print " [(set (match_dup 0) (match_dup 1))\n"; + } else { + $resultmode = $result; + if ( $result eq 'clobber' ) { $resultmode = $clobbermode } + print " [(set (match_dup 0) (${extend}_extend:${resultmode} (match_dup 1)))\n"; + } + print " (set (match_dup 2)\n"; + print " (compare:${ccmode} (match_dup 0) (match_dup 3)))]\n"; + print " \"\"\n"; + print " [(set_attr \"type\" \"fused_load_cmpi\")\n"; + print " (set_attr \"cost\" \"8\")\n"; + print " (set_attr \"length\" \"8\")])\n"; + print "\n"; + } } + } } sub gen_logical_addsubf diff --git a/gcc/testsuite/g++.target/powerpc/pr105325.C b/gcc/testsuite/g++.target/powerpc/pr105325.C deleted file mode 100644 index d0e66a0b897..00000000000 --- a/gcc/testsuite/g++.target/powerpc/pr105325.C +++ /dev/null @@ -1,26 +0,0 @@ -/* { dg-do assemble } */ -/* { dg-require-effective-target lp64 } */ -/* { dg-require-effective-target power10_ok } */ -/* { dg-require-effective-target powerpc_prefixed_addr } */ -/* { dg-options "-O2 -mdejagnu-cpu=power10 -fstack-protector" } */ - -/* Test that power10 fusion does not generate an LWA/CMPDI instruction pair - instead of PLWZ/CMPWI. Ultimately the code was dying because the fusion - load + compare -1/0/1 patterns did not handle the possibility that the load - might be prefixed. The -fstack-protector option is needed to show the - bug. */ - -struct Ath__array1D { - int _current; - int getCnt() { return _current; } -}; -struct extMeasure { - int _mapTable[10000]; - Ath__array1D _metRCTable; -}; -void measureRC() { - extMeasure m; - for (; m._metRCTable.getCnt();) - for (;;) - ; -} diff --git a/gcc/testsuite/gcc.target/powerpc/fusion-p10-ldcmpi.c b/gcc/testsuite/gcc.target/powerpc/fusion-p10-ldcmpi.c index ca7297375a4..526a026d874 100644 --- a/gcc/testsuite/gcc.target/powerpc/fusion-p10-ldcmpi.c +++ b/gcc/testsuite/gcc.target/powerpc/fusion-p10-ldcmpi.c @@ -61,7 +61,7 @@ TEST(int8_t) /* { dg-final { scan-assembler-times "lha_cmpdi_cr0_HI_clobber_CC_sign" 16 { target lp64 } } } */ /* { dg-final { scan-assembler-times "lhz_cmpldi_cr0_HI_clobber_CCUNS_zero" 4 { target lp64 } } } */ /* { dg-final { scan-assembler-times "lwa_cmpdi_cr0_SI_EXTSI_CC_sign" 0 { target lp64 } } } */ -/* { dg-final { scan-assembler-times "lwa_cmpdi_cr0_SI_clobber_CC_none" 8 { target lp64 } } } */ +/* { dg-final { scan-assembler-times "lwa_cmpdi_cr0_SI_clobber_CC_none" 4 { target lp64 } } } */ /* { dg-final { scan-assembler-times "lwz_cmpldi_cr0_SI_EXTSI_CCUNS_zero" 0 { target lp64 } } } */ /* { dg-final { scan-assembler-times "lwz_cmpldi_cr0_SI_clobber_CCUNS_none" 2 { target lp64 } } } */ @@ -73,6 +73,6 @@ TEST(int8_t) /* { dg-final { scan-assembler-times "lha_cmpdi_cr0_HI_clobber_CC_sign" 8 { target ilp32 } } } */ /* { dg-final { scan-assembler-times "lhz_cmpldi_cr0_HI_clobber_CCUNS_zero" 2 { target ilp32 } } } */ /* { dg-final { scan-assembler-times "lwa_cmpdi_cr0_SI_EXTSI_CC_sign" 0 { target ilp32 } } } */ -/* { dg-final { scan-assembler-times "lwa_cmpdi_cr0_SI_clobber_CC_none" 16 { target ilp32 } } } */ +/* { dg-final { scan-assembler-times "lwa_cmpdi_cr0_SI_clobber_CC_none" 9 { target ilp32 } } } */ /* { dg-final { scan-assembler-times "lwz_cmpldi_cr0_SI_EXTSI_CCUNS_zero" 0 { target ilp32 } } } */ /* { dg-final { scan-assembler-times "lwz_cmpldi_cr0_SI_clobber_CCUNS_none" 6 { target ilp32 } } } */