Skip to content

Commit 257a3a8

Browse files
committed
[AArch64][GlobalISel] Select G_ICMP Zero Instruction
1 parent 455f495 commit 257a3a8

File tree

6 files changed

+624
-1271
lines changed

6 files changed

+624
-1271
lines changed

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5397,6 +5397,52 @@ def : Pat<(AArch64bsp (v4i32 V128:$Rd), V128:$Rn, V128:$Rm),
53975397
def : Pat<(AArch64bsp (v2i64 V128:$Rd), V128:$Rn, V128:$Rm),
53985398
(BSPv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
53995399

5400+
multiclass SelectSetCCZeroRHS<PatFrags InFrag, string INST> {
5401+
def : Pat<(v8i8 (InFrag (v8i8 V64:$Rn), immAllZerosV)),
5402+
(v8i8 (!cast<Instruction>(INST # v8i8rz) (v8i8 V64:$Rn)))>;
5403+
def : Pat<(v16i8 (InFrag (v16i8 V128:$Rn), immAllZerosV)),
5404+
(v16i8 (!cast<Instruction>(INST # v16i8rz) (v16i8 V128:$Rn)))>;
5405+
def : Pat<(v4i16 (InFrag (v4i16 V64:$Rn), immAllZerosV)),
5406+
(v4i16 (!cast<Instruction>(INST # v4i16rz) (v4i16 V64:$Rn)))>;
5407+
def : Pat<(v8i16 (InFrag (v8i16 V128:$Rn), immAllZerosV)),
5408+
(v8i16 (!cast<Instruction>(INST # v8i16rz) (v8i16 V128:$Rn)))>;
5409+
def : Pat<(v2i32 (InFrag (v2i32 V64:$Rn), immAllZerosV)),
5410+
(v2i32 (!cast<Instruction>(INST # v2i32rz) (v2i32 V64:$Rn)))>;
5411+
def : Pat<(v4i32 (InFrag (v4i32 V128:$Rn), immAllZerosV)),
5412+
(v4i32 (!cast<Instruction>(INST # v4i32rz) (v4i32 V128:$Rn)))>;
5413+
def : Pat<(v2i64 (InFrag (v2i64 V128:$Rn), immAllZerosV)),
5414+
(v2i64 (!cast<Instruction>(INST # v2i64rz) (v2i64 V128:$Rn)))>;
5415+
}
5416+
5417+
defm : SelectSetCCZeroRHS<seteq, "CMEQ">;
5418+
defm : SelectSetCCZeroRHS<setgt, "CMGT">;
5419+
defm : SelectSetCCZeroRHS<setge, "CMGE">;
5420+
defm : SelectSetCCZeroRHS<setlt, "CMLT">;
5421+
defm : SelectSetCCZeroRHS<setle, "CMLE">;
5422+
5423+
multiclass SelectSetCCZeroLHS<PatFrags InFrag, string INST> {
5424+
def : Pat<(v8i8 (InFrag immAllZerosV, (v8i8 V64:$Rn))),
5425+
(v8i8 (!cast<Instruction>(INST # v8i8rz) (v8i8 V64:$Rn)))>;
5426+
def : Pat<(v16i8 (InFrag immAllZerosV, (v16i8 V128:$Rn))),
5427+
(v16i8 (!cast<Instruction>(INST # v16i8rz) (v16i8 V128:$Rn)))>;
5428+
def : Pat<(v4i16 (InFrag immAllZerosV, (v4i16 V64:$Rn))),
5429+
(v4i16 (!cast<Instruction>(INST # v4i16rz) (v4i16 V64:$Rn)))>;
5430+
def : Pat<(v8i16 (InFrag immAllZerosV, (v8i16 V128:$Rn))),
5431+
(v8i16 (!cast<Instruction>(INST # v8i16rz) (v8i16 V128:$Rn)))>;
5432+
def : Pat<(v2i32 (InFrag immAllZerosV, (v2i32 V64:$Rn))),
5433+
(v2i32 (!cast<Instruction>(INST # v2i32rz) (v2i32 V64:$Rn)))>;
5434+
def : Pat<(v4i32 (InFrag immAllZerosV, (v4i32 V128:$Rn))),
5435+
(v4i32 (!cast<Instruction>(INST # v4i32rz) (v4i32 V128:$Rn)))>;
5436+
def : Pat<(v2i64 (InFrag immAllZerosV, (v2i64 V128:$Rn))),
5437+
(v2i64 (!cast<Instruction>(INST # v2i64rz) (v2i64 V128:$Rn)))>;
5438+
}
5439+
5440+
defm : SelectSetCCZeroLHS<seteq, "CMEQ">;
5441+
defm : SelectSetCCZeroLHS<setgt, "CMLT">;
5442+
defm : SelectSetCCZeroLHS<setge, "CMLE">;
5443+
defm : SelectSetCCZeroLHS<setlt, "CMGT">;
5444+
defm : SelectSetCCZeroLHS<setle, "CMGE">;
5445+
54005446
let Predicates = [HasNEON] in {
54015447
def : InstAlias<"mov{\t$dst.16b, $src.16b|.16b\t$dst, $src}",
54025448
(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)