From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1005) id B66213858D28; Mon, 8 May 2023 23:20:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B66213858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683588036; bh=INTVkNaz/cInlmiH4VqxsYEEJzpZ+U0WmIpEZiSKDxA=; h=From:To:Subject:Date:From; b=NMCxUYpX8mwOkEIyIcb770Ly9IDf8Kxyj6g3kSokmJbBsWGT6R6ZTgFUvw5u60uzm VD+yr8UUNPjzqRRW7ibSomPDvBSs/6FNyL4tRPxzKLpUFZ+Qn8PdjXt7NOb8FCiBhU MpJZW1d8SFwTy0SYYJeA57k/tjWO1GhoMc46dP7I= 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: 1c9ca427b3d63f47bb7eb370a3aec8add4e9c66f X-Git-Newrev: 3d4bfa4137bc3d1daa7e3c308f8b6ec7c23f5943 Message-Id: <20230508232036.B66213858D28@sourceware.org> Date: Mon, 8 May 2023 23:20:36 +0000 (GMT) List-Id: https://gcc.gnu.org/g:3d4bfa4137bc3d1daa7e3c308f8b6ec7c23f5943 commit 3d4bfa4137bc3d1daa7e3c308f8b6ec7c23f5943 Author: Michael Meissner Date: Mon May 8 19:20:33 2023 -0400 Revert patches Diff: --- gcc/config/rs6000/genfusion.pl | 212 ++++++++++++++++++++++++----------------- 1 file changed, 126 insertions(+), 86 deletions(-) diff --git a/gcc/config/rs6000/genfusion.pl b/gcc/config/rs6000/genfusion.pl index e4db352e0ce..84de9ac3542 100755 --- a/gcc/config/rs6000/genfusion.pl +++ b/gcc/config/rs6000/genfusion.pl @@ -53,95 +53,135 @@ sub mode_to_ldst_char return '?'; } +# 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"). + +sub print_ld_cmpi_p10 +{ + my ($lmode, $result, $ccmode, $mem_format) = @_; + + my $ldst = mode_to_ldst_char($lmode); + + # Set various things based on whether the comparisons are signed or + # unsigned. + my ($cmpl, $const_pred, $sign_zero, $a_or_z) + = (($ccmode eq "CCUNS") + ? ("l", "const_0_to_1_operand", "zero", "z") + : ("", "const_m1_to_1_operand", "sign", "a")); + + # For clobber, we need a SI/DI reg in case we split because we have to + # sign/zero extend. + my $clobbermode = ($lmode =~ m/^(QI|HI)$/) ? "GPR" : $lmode; + + # We always need extension if result > lmode. + my $extend = (($result =~ m/^EXT/ + || $result eq "GPR" + || $clobbermode eq "GPR") ? $sign_zero : "none"); + + # DI-mode doesn't do sign/zero extension. + my $echr = ($lmode eq "DI") ? "" : $a_or_z; + + # Handle DS vs. D format memory. + my ($mempred, $np) = (($mem_format eq "ds") + ? ("ds_form_mem_operand", "NON_PREFIXED_DS") + : ("non_update_memory_operand", "NON_PREFIXED_D")); + + print ";; load-cmpi fusion pattern generated by gen_ld_cmpi_p10\n"; + + my $info = join (" ", + "load mode is ${lmode} result mode is ${result}", + "compare mode is ${ccmode} extend is ${extend}"); + + print ";; ${info}\n"; + + my $name = join ("", + "l${ldst}${echr}_cmp${cmpl}di_cr0_${lmode}", + "_${result}_${ccmode}_${extend}"); + + my $cmp_op1 = "(match_operand:${lmode} 1 \"${mempred}\" \"m\")"; + + my $spaces = " " x (length ($ccmode) + 18); + + 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"; + } + + 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 + { + 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"; + print " (set_attr \"length\" \"8\")])\n"; + print "\n"; +} + sub gen_ld_cmpi_p10 { - 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"; - } + my ($lmode, $result, $mempred, $np, $mem_format); + + foreach $lmode ("DI","SI", "HI", "QI") + { + foreach $result ("clobber", $lmode, "EXT${lmode}") + { + # EXTDI does not exist, and we cannot directly produce HI/QI results. + next if ($result =~ m/^(EXTDI|HI|QI)$/); + + # Don't allow EXTQI because that would allow HI result which we can't do. + $result = "GPR" if ($result eq "EXTQI"); + + # 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. + if ($lmode ne "QI") + { + $mem_format = ($lmode =~ m/^(DI|SI)$/) ? "ds" : "d"; + print_ld_cmpi_p10 ($lmode, $result, "CC", $mem_format); + } + + # Handle CCUNS mode (zero extended compares to 0 or 1. + # ld is DS-form, but lwz is not. + $mem_format = ($lmode eq "DI") ? "ds" : "d"; + + print_ld_cmpi_p10 ($lmode, $result, "CCUNS", $mem_format); + } } - } } sub gen_logical_addsubf