Index: llvm/lib/Target/CSKY/CSKYInstrInfo.td =================================================================== --- llvm/lib/Target/CSKY/CSKYInstrInfo.td +++ llvm/lib/Target/CSKY/CSKYInstrInfo.td @@ -1131,22 +1131,19 @@ // Branch Patterns. let Predicates = [iHasE2] in { - def : Pat<(brcond CARRY:$ca, bb:$imm16), +def : Pat<(brcond CARRY:$ca, bb:$imm16), (BT32 CARRY:$ca, bb:$imm16)>; - def : Pat<(brcond (i32 (setne GPR:$rs1, uimm16:$rs2)), bb:$imm16), - (BT32 (CMPNEI32 GPR:$rs1, uimm16:$rs2), bb:$imm16)>; - def : Pat<(brcond (i32 (seteq GPR:$rs1, uimm16:$rs2)), bb:$imm16), - (BF32 (CMPNEI32 GPR:$rs1, uimm16:$rs2), bb:$imm16)>; - def : Pat<(brcond (i32 (setuge GPR:$rs1, oimm16:$rs2)), bb:$imm16), - (BT32 (CMPHSI32 GPR:$rs1, oimm16:$rs2), bb:$imm16)>; - def : Pat<(brcond (i32 (setult GPR:$rs1, oimm16:$rs2)), bb:$imm16), - (BF32 (CMPHSI32 GPR:$rs1, oimm16:$rs2), bb:$imm16)>; - def : Pat<(brcond (i32 (setlt GPR:$rs1, oimm16:$rs2)), bb:$imm16), - (BT32 (CMPLTI32 GPR:$rs1, oimm16:$rs2), bb:$imm16)>; - def : Pat<(brcond (i32 (setge GPR:$rs1, oimm16:$rs2)), bb:$imm16), - (BF32 (CMPLTI32 GPR:$rs1, oimm16:$rs2), bb:$imm16)>; +multiclass BTF32Pat0 { + def : Pat<(brcond (i32 (cond0 GPR:$rs1, uimm16:$rs2)), bb:$imm16), + (BT32 (inst GPR:$rs1, imm_ty:$rs2), bb:$imm16)>; + def : Pat<(brcond (i32 (cond1 GPR:$rs1, uimm16:$rs2)), bb:$imm16), + (BF32 (inst GPR:$rs1, imm_ty:$rs2), bb:$imm16)>; +} +defm : BTF32Pat0; +defm : BTF32Pat0; +defm : BTF32Pat0; } let Predicates = [iHas2E3] in { @@ -1155,22 +1152,19 @@ (BT32 (CMPNE32 GPR:$rs1, GPR:$rs2), bb:$imm16)>; def : Pat<(brcond (i32 (seteq GPR:$rs1, GPR:$rs2)), bb:$imm16), (BF32 (CMPNE32 GPR:$rs1, GPR:$rs2), bb:$imm16)>; -def : Pat<(brcond (i32 (setuge GPR:$rs1, GPR:$rs2)), bb:$imm16), - (BT32 (CMPHS32 GPR:$rs1, GPR:$rs2), bb:$imm16)>; -def : Pat<(brcond (i32 (setule GPR:$rs1, GPR:$rs2)), bb:$imm16), - (BT32 (CMPHS32 GPR:$rs2, GPR:$rs1), bb:$imm16)>; -def : Pat<(brcond (i32 (setult GPR:$rs1, GPR:$rs2)), bb:$imm16), - (BF32 (CMPHS32 GPR:$rs1, GPR:$rs2), bb:$imm16)>; -def : Pat<(brcond (i32 (setugt GPR:$rs1, GPR:$rs2)), bb:$imm16), - (BF32 (CMPHS32 GPR:$rs2, GPR:$rs1), bb:$imm16)>; -def : Pat<(brcond (i32 (setlt GPR:$rs1, GPR:$rs2)), bb:$imm16), - (BT32 (CMPLT32 GPR:$rs1, GPR:$rs2), bb:$imm16)>; -def : Pat<(brcond (i32 (setgt GPR:$rs1, GPR:$rs2)), bb:$imm16), - (BT32 (CMPLT32 GPR:$rs2, GPR:$rs1), bb:$imm16)>; -def : Pat<(brcond (i32 (setge GPR:$rs1, GPR:$rs2)), bb:$imm16), - (BF32 (CMPLT32 GPR:$rs1, GPR:$rs2), bb:$imm16)>; -def : Pat<(brcond (i32 (setle GPR:$rs1, GPR:$rs2)), bb:$imm16), - (BF32 (CMPLT32 GPR:$rs2, GPR:$rs1), bb:$imm16)>; + +multiclass BTF32Pat1 { + def : Pat<(brcond (i32 (cond0 GPR:$rs1, GPR:$rs2)), bb:$imm16), + (br (cmp GPR:$rs1, GPR:$rs2), bb:$imm16)>; + def : Pat<(brcond (i32 (cond1 GPR:$rs1, GPR:$rs2)), bb:$imm16), + (br (cmp GPR:$rs2, GPR:$rs1), bb:$imm16)>; +} + +defm : BTF32Pat1; +defm : BTF32Pat1; +defm : BTF32Pat1; +defm : BTF32Pat1; def : Pat<(brcond (i32 (seteq GPR:$rs1, (i32 0))), bb:$imm16), (BEZ32 GPR:$rs1, bb:$imm16)>; @@ -1236,20 +1230,16 @@ def : Pat<(select (and CARRY:$ca, 1), GPR:$rx, GPR:$false), (MOVT32 CARRY:$ca, GPR:$rx, GPR:$false)>; -def : Pat<(select (i32 (setne GPR:$rs1, uimm16:$rs2)), GPR:$rx, GPR:$false), - (MOVT32 (CMPNEI32 GPR:$rs1, uimm16:$rs2), GPR:$rx, GPR:$false)>; -def : Pat<(select (i32 (seteq GPR:$rs1, uimm16:$rs2)), GPR:$rx, GPR:$false), - (MOVF32 (CMPNEI32 GPR:$rs1, uimm16:$rs2), GPR:$rx, GPR:$false)>; - -def : Pat<(select (i32 (setuge GPR:$rs1, oimm16:$rs2)), GPR:$rx, GPR:$false), - (MOVT32 (CMPHSI32 GPR:$rs1, oimm16:$rs2), GPR:$rx, GPR:$false)>; -def : Pat<(select (i32 (setult GPR:$rs1, oimm16:$rs2)), GPR:$rx, GPR:$false), - (MOVF32 (CMPHSI32 GPR:$rs1, oimm16:$rs2), GPR:$rx, GPR:$false)>; +multiclass MOVTF32Pat0 { + def : Pat<(select (i32 (cond0 GPR:$rs1, imm_ty:$rs2)), GPR:$rx, GPR:$false), + (MOVT32 (inst GPR:$rs1, imm_ty:$rs2), GPR:$rx, GPR:$false)>; + def : Pat<(select (i32 (cond1 GPR:$rs1, imm_ty:$rs2)), GPR:$rx, GPR:$false), + (MOVF32 (inst GPR:$rs1, imm_ty:$rs2), GPR:$rx, GPR:$false)>; +} -def : Pat<(select (i32 (setlt GPR:$rs1, oimm16:$rs2)), GPR:$rx, GPR:$false), - (MOVT32 (CMPLTI32 GPR:$rs1, oimm16:$rs2), GPR:$rx, GPR:$false)>; -def : Pat<(select (i32 (setge GPR:$rs1, oimm16:$rs2)), GPR:$rx, GPR:$false), - (MOVF32 (CMPLTI32 GPR:$rs1, oimm16:$rs2), GPR:$rx, GPR:$false)>; +defm : MOVTF32Pat0; +defm : MOVTF32Pat0; +defm : MOVTF32Pat0; def : Pat<(select CARRY:$ca, GPR:$rx, GPR:$false), (ISEL32 CARRY:$ca, GPR:$rx, GPR:$false)>; @@ -1265,24 +1255,18 @@ def : Pat<(select (i32 (seteq GPR:$rs1, GPR:$rs2)), GPR:$rx, GPR:$false), (MOVF32 (CMPNE32 GPR:$rs1, GPR:$rs2), GPR:$rx, GPR:$false)>; -def : Pat<(select (i32 (setuge GPR:$rs1, GPR:$rs2)), GPR:$rx, GPR:$false), - (MOVT32 (CMPHS32 GPR:$rs1, GPR:$rs2), GPR:$rx, GPR:$false)>; -def : Pat<(select (i32 (setule GPR:$rs1, GPR:$rs2)), GPR:$rx, GPR:$false), - (MOVT32 (CMPHS32 GPR:$rs2, GPR:$rs1), GPR:$rx, GPR:$false)>; -def : Pat<(select (i32 (setult GPR:$rs1, GPR:$rs2)), GPR:$rx, GPR:$false), - (MOVF32 (CMPHS32 GPR:$rs1, GPR:$rs2), GPR:$rx, GPR:$false)>; -def : Pat<(select (i32 (setugt GPR:$rs1, GPR:$rs2)), GPR:$rx, GPR:$false), - (MOVF32 (CMPHS32 GPR:$rs2, GPR:$rs1), GPR:$rx, GPR:$false)>; - -def : Pat<(select (i32 (setlt GPR:$rs1, GPR:$rs2)), GPR:$rx, GPR:$false), - (MOVT32 (CMPLT32 GPR:$rs1, GPR:$rs2), GPR:$rx, GPR:$false)>; -def : Pat<(select (i32 (setgt GPR:$rs1, GPR:$rs2)), GPR:$rx, GPR:$false), - (MOVT32 (CMPLT32 GPR:$rs2, GPR:$rs1), GPR:$rx, GPR:$false)>; -def : Pat<(select (i32 (setge GPR:$rs1, GPR:$rs2)), GPR:$rx, GPR:$false), - (MOVF32 (CMPLT32 GPR:$rs1, GPR:$rs2), GPR:$rx, GPR:$false)>; -def : Pat<(select (i32 (setle GPR:$rs1, GPR:$rs2)), GPR:$rx, GPR:$false), - (MOVF32 (CMPLT32 GPR:$rs2, GPR:$rs1), GPR:$rx, GPR:$false)>; +multiclass MOVTF32Pat1 { + def : Pat<(select (i32 (cond0 GPR:$rs1, GPR:$rs2)), GPR:$rx, GPR:$false), + (mov_inst (cmp_inst GPR:$rs1, GPR:$rs2), GPR:$rx, GPR:$false)>; + def : Pat<(select (i32 (cond1 GPR:$rs1, GPR:$rs2)), GPR:$rx, GPR:$false), + (mov_inst (cmp_inst GPR:$rs2, GPR:$rs1), GPR:$rx, GPR:$false)>; +} +defm : MOVTF32Pat1; +defm : MOVTF32Pat1; +defm : MOVTF32Pat1; +defm : MOVTF32Pat1; } // Constant materialize patterns. @@ -1353,9 +1337,6 @@ let mayLoad = 1, Size = 2, isCodeGenOnly = 0 in def PseudoLRW32 : CSKYPseudo<(outs GPR:$rz), (ins bare_symbol:$src), "lrw32 $rz, $src", []>; - - - let mayLoad = 1, Size = 4, isCodeGenOnly = 0 in def PseudoJSRI32 : CSKYPseudo<(outs), (ins call_symbol:$src), "jsri32 $src", []>; Index: llvm/lib/Target/CSKY/CSKYInstrInfo16Instr.td =================================================================== --- llvm/lib/Target/CSKY/CSKYInstrInfo16Instr.td +++ llvm/lib/Target/CSKY/CSKYInstrInfo16Instr.td @@ -483,39 +483,34 @@ def : Pat<(br bb:$offset), (BR16 bb:$offset)>; -def : Pat<(brcond (i32 (setne mGPR:$rs1, uimm5:$rs2)), bb:$offset), - (BT16 (CMPNEI16 mGPR:$rs1, uimm5:$rs2), bb:$offset)>; -def : Pat<(brcond (i32 (seteq mGPR:$rs1, uimm5:$rs2)), bb:$offset), - (BF16 (CMPNEI16 mGPR:$rs1, uimm5:$rs2), bb:$offset)>; -def : Pat<(brcond (i32 (setuge mGPR:$rs1, oimm5:$rs2)), bb:$offset), - (BT16 (CMPHSI16 mGPR:$rs1, oimm5:$rs2), bb:$offset)>; -def : Pat<(brcond (i32 (setult mGPR:$rs1, oimm5:$rs2)), bb:$offset), - (BF16 (CMPHSI16 mGPR:$rs1, oimm5:$rs2), bb:$offset)>; -def : Pat<(brcond (i32 (setlt mGPR:$rs1, oimm5:$rs2)), bb:$offset), - (BT16 (CMPLTI16 mGPR:$rs1, oimm5:$rs2), bb:$offset)>; -def : Pat<(brcond (i32 (setge mGPR:$rs1, oimm5:$rs2)), bb:$offset), - (BF16 (CMPLTI16 mGPR:$rs1, oimm5:$rs2), bb:$offset)>; +multiclass BTF16Pat0 { + def : Pat<(brcond (i32 (cond0 mGPR:$rs1, imm_ty:$rs2)), bb:$offset), + (BT16 (inst mGPR:$rs1, imm_ty:$rs2), bb:$offset)>; + def : Pat<(brcond (i32 (cond1 mGPR:$rs1, imm_ty:$rs2)), bb:$offset), + (BF16 (inst mGPR:$rs1, imm_ty:$rs2), bb:$offset)>; +} + +defm : BTF16Pat0; +defm : BTF16Pat0; +defm : BTF16Pat0; def : Pat<(brcond (i32 (setne sGPR:$rs1, sGPR:$rs2)), bb:$offset), (BT16 (CMPNE16 sGPR:$rs1, sGPR:$rs2), bb:$offset)>; def : Pat<(brcond (i32 (seteq sGPR:$rs1, sGPR:$rs2)), bb:$offset), (BF16 (CMPNE16 sGPR:$rs1, sGPR:$rs2), bb:$offset)>; -def : Pat<(brcond (i32 (setuge sGPR:$rs1, sGPR:$rs2)), bb:$offset), - (BT16 (CMPHS16 sGPR:$rs1, sGPR:$rs2), bb:$offset)>; -def : Pat<(brcond (i32 (setule sGPR:$rs1, sGPR:$rs2)), bb:$offset), - (BT16 (CMPHS16 sGPR:$rs2, sGPR:$rs1), bb:$offset)>; -def : Pat<(brcond (i32 (setult sGPR:$rs1, sGPR:$rs2)), bb:$offset), - (BF16 (CMPHS16 sGPR:$rs1, sGPR:$rs2), bb:$offset)>; -def : Pat<(brcond (i32 (setugt sGPR:$rs1, sGPR:$rs2)), bb:$offset), - (BF16 (CMPHS16 sGPR:$rs2, sGPR:$rs1), bb:$offset)>; -def : Pat<(brcond (i32 (setlt sGPR:$rs1, sGPR:$rs2)), bb:$offset), - (BT16 (CMPLT16 sGPR:$rs1, sGPR:$rs2), bb:$offset)>; -def : Pat<(brcond (i32 (setgt sGPR:$rs1, sGPR:$rs2)), bb:$offset), - (BT16 (CMPLT16 sGPR:$rs2, sGPR:$rs1), bb:$offset)>; -def : Pat<(brcond (i32 (setge sGPR:$rs1, sGPR:$rs2)), bb:$offset), - (BF16 (CMPLT16 sGPR:$rs1, sGPR:$rs2), bb:$offset)>; -def : Pat<(brcond (i32 (setle sGPR:$rs1, sGPR:$rs2)), bb:$offset), - (BF16 (CMPLT16 sGPR:$rs2, sGPR:$rs1), bb:$offset)>; + +multiclass BTF16Pat1 { + def : Pat<(brcond (i32 (cond0 sGPR:$rs1, sGPR:$rs2)), bb:$offset), + (br (cmp sGPR:$rs1, sGPR:$rs2), bb:$offset)>; + def : Pat<(brcond (i32 (cond1 sGPR:$rs1, sGPR:$rs2)), bb:$offset), + (br (cmp sGPR:$rs2, sGPR:$rs1), bb:$offset)>; +} + +defm : BTF16Pat1; +defm : BTF16Pat1; +defm : BTF16Pat1; +defm : BTF16Pat1; // Compare Patterns. def : Pat<(setne sGPR:$rs1, sGPR:$rs2),