diff --git a/llvm/lib/Target/AArch64/SVEInstrFormats.td b/llvm/lib/Target/AArch64/SVEInstrFormats.td --- a/llvm/lib/Target/AArch64/SVEInstrFormats.td +++ b/llvm/lib/Target/AArch64/SVEInstrFormats.td @@ -4741,6 +4741,10 @@ (cmp $Op1, $Op2)>; def : Pat<(predvt (AArch64setcc_z predvt:$Op1, (SVEDup0), intvt:$Op2, invcc)), (cmp $Op1, $Op2)>; + def : Pat<(predvt (and predvt:$Pg, (AArch64setcc_z (predvt (AArch64ptrue 31)), intvt:$Op1, (SVEDup0), cc))), + (cmp $Pg, $Op1)>; + def : Pat<(predvt (and predvt:$Pg, (AArch64setcc_z (predvt (AArch64ptrue 31)), (SVEDup0), intvt:$Op1, invcc))), + (cmp $Pg, $Op1)>; } multiclass sve_int_cmp_0 opc, string asm, CondCode cc, CondCode invcc> { @@ -4812,14 +4816,26 @@ ValueType predvt, ValueType intvt, Operand immtype, Instruction cmp> { def : Pat<(predvt (AArch64setcc_z (predvt PPR_3b:$Pg), - (intvt ZPR:$Zs1), - (intvt (splat_vector (immtype:$imm))), - cc)), + (intvt ZPR:$Zs1), + (intvt (splat_vector (immtype:$imm))), + cc)), (cmp $Pg, $Zs1, immtype:$imm)>; def : Pat<(predvt (AArch64setcc_z (predvt PPR_3b:$Pg), - (intvt (splat_vector (immtype:$imm))), - (intvt ZPR:$Zs1), - commuted_cc)), + (intvt (splat_vector (immtype:$imm))), + (intvt ZPR:$Zs1), + commuted_cc)), + (cmp $Pg, $Zs1, immtype:$imm)>; + def : Pat<(predvt (and predvt:$Pg, + (AArch64setcc_z (predvt (AArch64ptrue 31)), + (intvt ZPR:$Zs1), + (intvt (splat_vector (immtype:$imm))), + cc))), + (cmp $Pg, $Zs1, immtype:$imm)>; + def : Pat<(predvt (and predvt:$Pg, + (AArch64setcc_z (predvt (AArch64ptrue 31)), + (intvt (splat_vector (immtype:$imm))), + (intvt ZPR:$Zs1), + commuted_cc))), (cmp $Pg, $Zs1, immtype:$imm)>; } diff --git a/llvm/test/CodeGen/AArch64/sve-fcmp.ll b/llvm/test/CodeGen/AArch64/sve-fcmp.ll --- a/llvm/test/CodeGen/AArch64/sve-fcmp.ll +++ b/llvm/test/CodeGen/AArch64/sve-fcmp.ll @@ -435,8 +435,7 @@ define @oeq_zero_pred( %pg, %x) { ; CHECK-LABEL: oeq_zero_pred: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.h, #0 // =0x0 -; CHECK-NEXT: fcmeq p0.h, p0/z, z0.h, z1.h +; CHECK-NEXT: fcmeq p0.h, p0/z, z0.h, #0.0 ; CHECK-NEXT: ret %y = fcmp oeq %x, zeroinitializer %z = and %pg, %y @@ -445,8 +444,7 @@ define @ogt_zero_pred( %pg, %x) { ; CHECK-LABEL: ogt_zero_pred: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.h, #0 // =0x0 -; CHECK-NEXT: fcmgt p0.h, p0/z, z0.h, z1.h +; CHECK-NEXT: fcmgt p0.h, p0/z, z0.h, #0.0 ; CHECK-NEXT: ret %y = fcmp ogt %x, zeroinitializer %z = and %pg, %y @@ -455,8 +453,7 @@ define @oge_zero_pred( %pg, %x) { ; CHECK-LABEL: oge_zero_pred: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.h, #0 // =0x0 -; CHECK-NEXT: fcmge p0.h, p0/z, z0.h, z1.h +; CHECK-NEXT: fcmge p0.h, p0/z, z0.h, #0.0 ; CHECK-NEXT: ret %y = fcmp oge %x, zeroinitializer %z = and %pg, %y @@ -465,8 +462,7 @@ define @olt_zero_pred( %pg, %x) { ; CHECK-LABEL: olt_zero_pred: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.s, #0 // =0x0 -; CHECK-NEXT: fcmgt p0.s, p0/z, z1.s, z0.s +; CHECK-NEXT: fcmlt p0.s, p0/z, z0.s, #0.0 ; CHECK-NEXT: ret %y = fcmp olt %x, zeroinitializer %z = and %pg, %y @@ -475,8 +471,7 @@ define @ole_zero_pred( %pg, %x) { ; CHECK-LABEL: ole_zero_pred: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.s, #0 // =0x0 -; CHECK-NEXT: fcmge p0.s, p0/z, z1.s, z0.s +; CHECK-NEXT: fcmle p0.s, p0/z, z0.s, #0.0 ; CHECK-NEXT: ret %y = fcmp ole %x, zeroinitializer %z = and %pg, %y @@ -485,8 +480,7 @@ define @une_zero_pred( %pg, %x) { ; CHECK-LABEL: une_zero_pred: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.d, #0 // =0x0 -; CHECK-NEXT: fcmne p0.d, p0/z, z0.d, z1.d +; CHECK-NEXT: fcmne p0.d, p0/z, z0.d, #0.0 ; CHECK-NEXT: ret %y = fcmp une %x, zeroinitializer %z = and %pg, %y diff --git a/llvm/test/CodeGen/AArch64/sve-fixed-length-ptest.ll b/llvm/test/CodeGen/AArch64/sve-fixed-length-ptest.ll --- a/llvm/test/CodeGen/AArch64/sve-fixed-length-ptest.ll +++ b/llvm/test/CodeGen/AArch64/sve-fixed-length-ptest.ll @@ -112,8 +112,7 @@ ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0] ; CHECK-NEXT: ld1w { z1.s }, p0/z, [x1] ; CHECK-NEXT: fcmne p0.s, p0/z, z0.s, #0.0 -; CHECK-NEXT: mov z0.s, #0 // =0x0 -; CHECK-NEXT: fcmne p0.s, p0/z, z1.s, z0.s +; CHECK-NEXT: fcmne p0.s, p0/z, z1.s, #0.0 ; CHECK-NEXT: mov z0.s, p0/z, #-1 // =0xffffffffffffffff ; CHECK-NEXT: ptrue p0.b, vl16 ; CHECK-NEXT: uzp1 z0.h, z0.h, z0.h diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-int-compares.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-int-compares.ll --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-int-compares.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-int-compares.ll @@ -1099,8 +1099,7 @@ define @predicated_icmp_eq_imm( %a, %b) { ; CHECK-LABEL: predicated_icmp_eq_imm: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.b, #0 // =0x0 -; CHECK-NEXT: cmpeq p0.b, p0/z, z0.b, z1.b +; CHECK-NEXT: cmpeq p0.b, p0/z, z0.b, #0 ; CHECK-NEXT: ret %imm = shufflevector insertelement ( undef, i8 0, i64 0), undef, zeroinitializer %icmp = icmp eq %b, %imm @@ -1111,8 +1110,7 @@ define @predicated_icmp_ne_imm( %a, %b) { ; CHECK-LABEL: predicated_icmp_ne_imm: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.h, #-16 // =0xfffffffffffffff0 -; CHECK-NEXT: cmpne p0.h, p0/z, z0.h, z1.h +; CHECK-NEXT: cmpne p0.h, p0/z, z0.h, #-16 ; CHECK-NEXT: ret %imm = shufflevector insertelement ( undef, i16 -16, i64 0), undef, zeroinitializer %icmp = icmp ne %b, %imm @@ -1123,8 +1121,7 @@ define @predicated_icmp_sge_imm( %a, %b) { ; CHECK-LABEL: predicated_icmp_sge_imm: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.s, #1 // =0x1 -; CHECK-NEXT: cmpge p0.s, p0/z, z0.s, z1.s +; CHECK-NEXT: cmpge p0.s, p0/z, z0.s, #1 ; CHECK-NEXT: ret %imm = shufflevector insertelement ( undef, i32 1, i64 0), undef, zeroinitializer %icmp = icmp sge %b, %imm @@ -1135,8 +1132,7 @@ define @predicated_icmp_sgt_imm( %a, %b) { ; CHECK-LABEL: predicated_icmp_sgt_imm: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.d, #2 // =0x2 -; CHECK-NEXT: cmpgt p0.d, p0/z, z0.d, z1.d +; CHECK-NEXT: cmpgt p0.d, p0/z, z0.d, #2 ; CHECK-NEXT: ret %imm = shufflevector insertelement ( undef, i64 2, i64 0), undef, zeroinitializer %icmp = icmp sgt %b, %imm @@ -1147,8 +1143,7 @@ define @predicated_icmp_sle_imm( %a, %b) { ; CHECK-LABEL: predicated_icmp_sle_imm: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.b, #-1 // =0xffffffffffffffff -; CHECK-NEXT: cmpge p0.b, p0/z, z1.b, z0.b +; CHECK-NEXT: cmple p0.b, p0/z, z0.b, #-1 ; CHECK-NEXT: ret %imm = shufflevector insertelement ( undef, i8 -1, i64 0), undef, zeroinitializer %icmp = icmp sle %b, %imm @@ -1159,8 +1154,7 @@ define @predicated_icmp_slt_imm( %a, %b) { ; CHECK-LABEL: predicated_icmp_slt_imm: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.h, #-2 // =0xfffffffffffffffe -; CHECK-NEXT: cmpgt p0.h, p0/z, z1.h, z0.h +; CHECK-NEXT: cmplt p0.h, p0/z, z0.h, #-2 ; CHECK-NEXT: ret %imm = shufflevector insertelement ( undef, i16 -2, i64 0), undef, zeroinitializer %icmp = icmp slt %b, %imm @@ -1171,8 +1165,7 @@ define @predicated_icmp_uge_imm( %a, %b) { ; CHECK-LABEL: predicated_icmp_uge_imm: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.s, #1 // =0x1 -; CHECK-NEXT: cmphs p0.s, p0/z, z0.s, z1.s +; CHECK-NEXT: cmphs p0.s, p0/z, z0.s, #1 ; CHECK-NEXT: ret %imm = shufflevector insertelement ( undef, i32 1, i64 0), undef, zeroinitializer %icmp = icmp uge %b, %imm @@ -1183,8 +1176,7 @@ define @predicated_icmp_ugt_imm( %a, %b) { ; CHECK-LABEL: predicated_icmp_ugt_imm: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.d, #2 // =0x2 -; CHECK-NEXT: cmphi p0.d, p0/z, z0.d, z1.d +; CHECK-NEXT: cmphi p0.d, p0/z, z0.d, #2 ; CHECK-NEXT: ret %imm = shufflevector insertelement ( undef, i64 2, i64 0), undef, zeroinitializer %icmp = icmp ugt %b, %imm @@ -1195,8 +1187,7 @@ define @predicated_icmp_ule_imm( %a, %b) { ; CHECK-LABEL: predicated_icmp_ule_imm: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.b, #3 // =0x3 -; CHECK-NEXT: cmphs p0.b, p0/z, z1.b, z0.b +; CHECK-NEXT: cmpls p0.b, p0/z, z0.b, #3 ; CHECK-NEXT: ret %imm = shufflevector insertelement ( undef, i8 3, i64 0), undef, zeroinitializer %icmp = icmp ule %b, %imm @@ -1207,8 +1198,7 @@ define @predicated_icmp_ult_imm( %a, %b) { ; CHECK-LABEL: predicated_icmp_ult_imm: ; CHECK: // %bb.0: -; CHECK-NEXT: mov z1.h, #127 // =0x7f -; CHECK-NEXT: cmphi p0.h, p0/z, z1.h, z0.h +; CHECK-NEXT: cmplo p0.h, p0/z, z0.h, #127 ; CHECK-NEXT: ret %imm = shufflevector insertelement ( undef, i16 127, i64 0), undef, zeroinitializer %icmp = icmp ult %b, %imm