From 36c639483f26c2052c21594695d93c75e348f720 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 14 Nov 2024 08:53:35 -0800 Subject: [PATCH] [RISCV] Add VTs to some multi instruction isel patterns to resolve ambiguity. See also #81192. These were found by disabling tablegen's ForceArbitraryInstResultType. For one of the patterns I was able to get a failure if Zfh was enabled, but Zfbfmin was not. It appears ForceArbitraryInstResultType picks bf16 over f16. I think something like #116165 is a better long term fix for these issues. I will update that to include f16/bf16. --- llvm/lib/Target/RISCV/RISCVInstrInfoD.td | 2 +- llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td index b5e1298c7770a8..0de43c458f22ca 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td @@ -325,7 +325,7 @@ def : PatFprFpr; def : Pat<(fcopysign FPR64INX:$rs1, (fneg FPR64INX:$rs2)), (FSGNJN_D_INX $rs1, $rs2)>; def : Pat<(fcopysign FPR64INX:$rs1, FPR32INX:$rs2), - (FSGNJ_D_INX $rs1, (FCVT_D_S_INX $rs2, FRM_RNE))>; + (FSGNJ_D_INX $rs1, (f64 (FCVT_D_S_INX $rs2, FRM_RNE)))>; def : Pat<(fcopysign FPR32INX:$rs1, FPR64INX:$rs2), (FSGNJ_S_INX $rs1, (FCVT_S_D_INX $rs2, FRM_DYN))>; diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td index ccf13e07ef193f..e2e99cc3f2b72c 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td @@ -293,7 +293,7 @@ def : PatFprFpr; def : PatFprFpr; def : Pat<(f16 (fcopysign FPR16:$rs1, (f16 (fneg FPR16:$rs2)))), (FSGNJN_H $rs1, $rs2)>; def : Pat<(f16 (fcopysign FPR16:$rs1, FPR32:$rs2)), - (FSGNJ_H $rs1, (FCVT_H_S $rs2, FRM_DYN))>; + (FSGNJ_H $rs1, (f16 (FCVT_H_S $rs2, FRM_DYN)))>; // fmadd: rs1 * rs2 + rs3 def : Pat<(f16 (any_fma FPR16:$rs1, FPR16:$rs2, FPR16:$rs3)), @@ -588,7 +588,7 @@ def : Pat<(any_fpextend (f16 FPR16:$rs1)), (FCVT_D_H FPR16:$rs1, FRM_RNE)>; /// Float arithmetic operations def : Pat<(f16 (fcopysign FPR16:$rs1, FPR64:$rs2)), - (FSGNJ_H $rs1, (FCVT_H_D $rs2, FRM_DYN))>; + (FSGNJ_H $rs1, (f16 (FCVT_H_D $rs2, FRM_DYN)))>; def : Pat<(fcopysign FPR64:$rs1, (f16 FPR16:$rs2)), (FSGNJ_D $rs1, (FCVT_D_H $rs2, FRM_RNE))>; } // Predicates = [HasStdExtZfhmin, HasStdExtD] @@ -613,5 +613,5 @@ def : Pat<(any_fpextend FPR16INX:$rs1), (FCVT_D_H_INX FPR16INX:$rs1, FRM_RNE)>; /// Float arithmetic operations def : Pat<(fcopysign FPR16INX:$rs1, FPR64INX:$rs2), (FSGNJ_H_INX $rs1, (FCVT_H_D_INX $rs2, 0b111))>; -def : Pat<(fcopysign FPR64INX:$rs1, FPR16INX:$rs2), (FSGNJ_D_INX $rs1, (FCVT_D_H_INX $rs2, FRM_RNE))>; +def : Pat<(fcopysign FPR64INX:$rs1, FPR16INX:$rs2), (FSGNJ_D_INX $rs1, (f64 (FCVT_D_H_INX $rs2, FRM_RNE)))>; } // Predicates = [HasStdExtZhinxmin, HasStdExtZdinx, IsRV64]