@@ -338,3 +338,41 @@ let AdditionalPredicates = [NotInMips16Mode, NotInMicroMips,
338338 GPR64Opnd>,
339339 ISA_MIPS64R6;
340340}
341+
342+ // Combining branch and set instructions into one compact branch instruction
343+ let AdditionalPredicates = [NotInMicroMips, UseCompactBranches] in {
344+ def : MipsPat<(brcond (i32 (setlt i64:$rs, 0)), bb:$offset),
345+ (BLTZC64 GPR64Opnd:$rs, bb:$offset)>, ISA_MIPS64R6;
346+ def : MipsPat<(brcond (i32 (setlt i64:$rs, 1)), bb:$offset),
347+ (BLEZC64 GPR64Opnd:$rs, bb:$offset)>, ISA_MIPS64R6;
348+ def : MipsPat<(brcond (i32 (setge i64:$rs, 0)), bb:$offset),
349+ (BGEZC64 GPR64Opnd:$rs, bb:$offset)>, ISA_MIPS64R6;
350+ def : MipsPat<(brcond (i32 (setge i64:$rs, 1)), bb:$offset),
351+ (BGTZC64 GPR64Opnd:$rs, bb:$offset)>, ISA_MIPS64R6;
352+ def : MipsPat<(brcond (i32 (setgt i64:$rs, 0)), bb:$offset),
353+ (BGTZC64 GPR64Opnd:$rs, bb:$offset)>, ISA_MIPS64R6;
354+ def : MipsPat<(brcond (i32 (setgt i64:$rs, -1)), bb:$offset),
355+ (BGEZC64 GPR64Opnd:$rs, bb:$offset)>, ISA_MIPS64R6;
356+ def : MipsPat<(brcond (i32 (setle i64:$rs, 0)), bb:$offset),
357+ (BLEZC64 GPR64Opnd:$rs, bb:$offset)>, ISA_MIPS64R6;
358+ def : MipsPat<(brcond (i32 (setle i64:$rs, -1)), bb:$offset),
359+ (BLTZC64 GPR64Opnd:$rs, bb:$offset)>, ISA_MIPS64R6;
360+
361+ def : MipsPat<(brcond (i32 (setlt GPR64:$rs, GPR64:$rt)), bb:$offset),
362+ (BLTC64 GPR64:$rs, GPR64:$rt, bb:$offset)>, ISA_MIPS64R6;
363+ def : MipsPat<(brcond (i32 (setge GPR64:$rs, GPR64:$rt)), bb:$offset),
364+ (BGEC64 GPR64:$rs, GPR64:$rt, bb:$offset)>, ISA_MIPS64R6;
365+ def : MipsPat<(brcond (i32 (setgt GPR64:$rs, GPR64:$rt)), bb:$offset),
366+ (BLTC64 GPR64:$rt, GPR64:$rs, bb:$offset)>, ISA_MIPS64R6;
367+ def : MipsPat<(brcond (i32 (setle GPR64:$rs, GPR64:$rt)), bb:$offset),
368+ (BGEC64 GPR64:$rt, GPR64:$rs, bb:$offset)>, ISA_MIPS64R6;
369+
370+ def : MipsPat<(brcond (i32 (setult GPR64:$rs, GPR64:$rt)), bb:$offset),
371+ (BLTUC64 GPR64:$rs, GPR64:$rt, bb:$offset)>, ISA_MIPS64R6;
372+ def : MipsPat<(brcond (i32 (setuge GPR64:$rs, GPR64:$rt)), bb:$offset),
373+ (BGEUC64 GPR64:$rs, GPR64:$rt, bb:$offset)>, ISA_MIPS64R6;
374+ def : MipsPat<(brcond (i32 (setugt GPR64:$rs, GPR64:$rt)), bb:$offset),
375+ (BLTUC64 GPR64:$rt, GPR64:$rs, bb:$offset)>, ISA_MIPS64R6;
376+ def : MipsPat<(brcond (i32 (setule GPR64:$rs, GPR64:$rt)), bb:$offset),
377+ (BGEUC64 GPR64:$rt, GPR64:$rs, bb:$offset)>, ISA_MIPS64R6;
378+ }
0 commit comments