Skip to content

Commit 2612dc9

Browse files
authored
[X86][APX] Add pattern for zext(X86setcc ..) -> SETZUCCr (#170806)
1 parent 5a74f7e commit 2612dc9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

llvm/lib/Target/X86/X86InstrCMovSetCC.td

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ let Uses = [EFLAGS], isCodeGenOnly = 1, ForceDisassemble = 1 in {
150150

151151
// SetZUCC and promoted SetCC instructions.
152152
let Uses = [EFLAGS], isCodeGenOnly = 1, ForceDisassemble = 1,
153-
hasSideEffects = 0, Predicates = [In64BitMode], Predicates = [HasNDD] in {
153+
hasSideEffects = 0, Predicates = [In64BitMode] in {
154154
def SETZUCCr : I<0x40, MRMXrCC, (outs GR8:$dst), (ins ccode:$cond),
155155
"setzu${cond}\t$dst", []>,
156156
XD, ZU, NoCD8, Sched<[WriteSETCC]>;
@@ -167,6 +167,10 @@ let Uses = [EFLAGS], isCodeGenOnly = 1, ForceDisassemble = 1,
167167
}
168168
}
169169

170+
let Predicates = [HasZU] in
171+
def : Pat<(i32 (zext (X86setcc timm:$cond, EFLAGS))),
172+
(INSERT_SUBREG (i32 (IMPLICIT_DEF)), (SETZUCCr ccode:$cond), sub_8bit)>;
173+
170174
// SALC is an undocumented instruction. Information for this instruction can be found
171175
// here http://www.rcollins.org/secrets/opcodes/SALC.html
172176
// Set AL if carry.

llvm/test/CodeGen/X86/apx/setzucc.ll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,15 @@ bb1:
8989
bb2:
9090
ret i32 0
9191
}
92+
93+
define i32 @highmask_i32_mask32(i32 %val) {
94+
; CHECK-LABEL: highmask_i32_mask32:
95+
; CHECK: # %bb.0:
96+
; CHECK-NEXT: testl $-1048576, %edi # imm = 0xFFF00000
97+
; CHECK-NEXT: setzune %al
98+
; CHECK-NEXT: retq
99+
%and = and i32 %val, -1048576
100+
%cmp = icmp ne i32 %and, 0
101+
%ret = zext i1 %cmp to i32
102+
ret i32 %ret
103+
}

0 commit comments

Comments
 (0)