Skip to content

Commit 0bc23f1

Browse files
authored
[AArch64][GlobalISel] Select G_ICMP Zero Instruction (#90054)
1 parent d9be51c commit 0bc23f1

File tree

6 files changed

+640
-1303
lines changed

6 files changed

+640
-1303
lines changed

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5449,6 +5449,52 @@ defm : SelectSetCCSwapOperands<setle, "CMGE">;
54495449
defm : SelectSetCCSwapOperands<setult, "CMHI">;
54505450
defm : SelectSetCCSwapOperands<setule, "CMHS">;
54515451

5452+
multiclass SelectSetCCZeroRHS<PatFrags InFrag, string INST> {
5453+
def : Pat<(v8i8 (InFrag (v8i8 V64:$Rn), immAllZerosV)),
5454+
(v8i8 (!cast<Instruction>(INST # v8i8rz) (v8i8 V64:$Rn)))>;
5455+
def : Pat<(v16i8 (InFrag (v16i8 V128:$Rn), immAllZerosV)),
5456+
(v16i8 (!cast<Instruction>(INST # v16i8rz) (v16i8 V128:$Rn)))>;
5457+
def : Pat<(v4i16 (InFrag (v4i16 V64:$Rn), immAllZerosV)),
5458+
(v4i16 (!cast<Instruction>(INST # v4i16rz) (v4i16 V64:$Rn)))>;
5459+
def : Pat<(v8i16 (InFrag (v8i16 V128:$Rn), immAllZerosV)),
5460+
(v8i16 (!cast<Instruction>(INST # v8i16rz) (v8i16 V128:$Rn)))>;
5461+
def : Pat<(v2i32 (InFrag (v2i32 V64:$Rn), immAllZerosV)),
5462+
(v2i32 (!cast<Instruction>(INST # v2i32rz) (v2i32 V64:$Rn)))>;
5463+
def : Pat<(v4i32 (InFrag (v4i32 V128:$Rn), immAllZerosV)),
5464+
(v4i32 (!cast<Instruction>(INST # v4i32rz) (v4i32 V128:$Rn)))>;
5465+
def : Pat<(v2i64 (InFrag (v2i64 V128:$Rn), immAllZerosV)),
5466+
(v2i64 (!cast<Instruction>(INST # v2i64rz) (v2i64 V128:$Rn)))>;
5467+
}
5468+
5469+
defm : SelectSetCCZeroRHS<seteq, "CMEQ">;
5470+
defm : SelectSetCCZeroRHS<setgt, "CMGT">;
5471+
defm : SelectSetCCZeroRHS<setge, "CMGE">;
5472+
defm : SelectSetCCZeroRHS<setlt, "CMLT">;
5473+
defm : SelectSetCCZeroRHS<setle, "CMLE">;
5474+
5475+
multiclass SelectSetCCZeroLHS<PatFrags InFrag, string INST> {
5476+
def : Pat<(v8i8 (InFrag immAllZerosV, (v8i8 V64:$Rn))),
5477+
(v8i8 (!cast<Instruction>(INST # v8i8rz) (v8i8 V64:$Rn)))>;
5478+
def : Pat<(v16i8 (InFrag immAllZerosV, (v16i8 V128:$Rn))),
5479+
(v16i8 (!cast<Instruction>(INST # v16i8rz) (v16i8 V128:$Rn)))>;
5480+
def : Pat<(v4i16 (InFrag immAllZerosV, (v4i16 V64:$Rn))),
5481+
(v4i16 (!cast<Instruction>(INST # v4i16rz) (v4i16 V64:$Rn)))>;
5482+
def : Pat<(v8i16 (InFrag immAllZerosV, (v8i16 V128:$Rn))),
5483+
(v8i16 (!cast<Instruction>(INST # v8i16rz) (v8i16 V128:$Rn)))>;
5484+
def : Pat<(v2i32 (InFrag immAllZerosV, (v2i32 V64:$Rn))),
5485+
(v2i32 (!cast<Instruction>(INST # v2i32rz) (v2i32 V64:$Rn)))>;
5486+
def : Pat<(v4i32 (InFrag immAllZerosV, (v4i32 V128:$Rn))),
5487+
(v4i32 (!cast<Instruction>(INST # v4i32rz) (v4i32 V128:$Rn)))>;
5488+
def : Pat<(v2i64 (InFrag immAllZerosV, (v2i64 V128:$Rn))),
5489+
(v2i64 (!cast<Instruction>(INST # v2i64rz) (v2i64 V128:$Rn)))>;
5490+
}
5491+
5492+
defm : SelectSetCCZeroLHS<seteq, "CMEQ">;
5493+
defm : SelectSetCCZeroLHS<setgt, "CMLT">;
5494+
defm : SelectSetCCZeroLHS<setge, "CMLE">;
5495+
defm : SelectSetCCZeroLHS<setlt, "CMGT">;
5496+
defm : SelectSetCCZeroLHS<setle, "CMGE">;
5497+
54525498
let Predicates = [HasNEON] in {
54535499
def : InstAlias<"mov{\t$dst.16b, $src.16b|.16b\t$dst, $src}",
54545500
(ORRv16i8 V128:$dst, V128:$src, V128:$src), 1>;

llvm/test/CodeGen/AArch64/aarch64-addv.ll

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,19 @@ define i32 @oversized_ADDV_256(ptr noalias nocapture readonly %arg1, ptr noalias
9494
;
9595
; GISEL-LABEL: oversized_ADDV_256:
9696
; GISEL: // %bb.0: // %entry
97-
; GISEL-NEXT: ldr d1, [x0]
98-
; GISEL-NEXT: ldr d2, [x1]
99-
; GISEL-NEXT: movi v0.2d, #0000000000000000
97+
; GISEL-NEXT: ldr d0, [x0]
98+
; GISEL-NEXT: ldr d1, [x1]
99+
; GISEL-NEXT: ushll v0.8h, v0.8b, #0
100100
; GISEL-NEXT: ushll v1.8h, v1.8b, #0
101-
; GISEL-NEXT: ushll v2.8h, v2.8b, #0
102-
; GISEL-NEXT: usubl v3.4s, v1.4h, v2.4h
103-
; GISEL-NEXT: usubl2 v1.4s, v1.8h, v2.8h
104-
; GISEL-NEXT: cmgt v2.4s, v0.4s, v3.4s
105-
; GISEL-NEXT: cmgt v0.4s, v0.4s, v1.4s
106-
; GISEL-NEXT: neg v4.4s, v3.4s
107-
; GISEL-NEXT: neg v5.4s, v1.4s
108-
; GISEL-NEXT: bsl v2.16b, v4.16b, v3.16b
109-
; GISEL-NEXT: bsl v0.16b, v5.16b, v1.16b
110-
; GISEL-NEXT: add v0.4s, v2.4s, v0.4s
101+
; GISEL-NEXT: usubl v2.4s, v0.4h, v1.4h
102+
; GISEL-NEXT: usubl2 v0.4s, v0.8h, v1.8h
103+
; GISEL-NEXT: cmlt v1.4s, v2.4s, #0
104+
; GISEL-NEXT: cmlt v3.4s, v0.4s, #0
105+
; GISEL-NEXT: neg v4.4s, v2.4s
106+
; GISEL-NEXT: neg v5.4s, v0.4s
107+
; GISEL-NEXT: bsl v1.16b, v4.16b, v2.16b
108+
; GISEL-NEXT: bit v0.16b, v5.16b, v3.16b
109+
; GISEL-NEXT: add v0.4s, v1.4s, v0.4s
111110
; GISEL-NEXT: addv s0, v0.4s
112111
; GISEL-NEXT: fmov w0, s0
113112
; GISEL-NEXT: ret

0 commit comments

Comments
 (0)