Skip to content

Commit f35e3b9

Browse files
committed
Revert "[X86] combineAndNotOrIntoAndNotAnd - don't attempt with constant operands"
This reverts commit ec78f0d.
1 parent 4679583 commit f35e3b9

File tree

2 files changed

+8
-60
lines changed

2 files changed

+8
-60
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50047,15 +50047,12 @@ static SDValue combineAndNotOrIntoAndNotAnd(SDNode *N, SelectionDAG &DAG) {
5004750047
return SDValue();
5004850048

5004950049
SDValue X, Y, Z;
50050-
if (sd_match(N, m_And(m_Value(X),
50051-
m_OneUse(m_Or(m_Value(Y), m_Not(m_Value(Z))))))) {
50052-
// Don't fold if Y is a constant to prevent infinite loops.
50053-
if (!isa<ConstantSDNode>(Y))
50054-
return DAG.getNode(
50055-
ISD::AND, DL, VT, X,
50056-
DAG.getNOT(
50057-
DL, DAG.getNode(ISD::AND, DL, VT, DAG.getNOT(DL, Y, VT), Z), VT));
50058-
}
50050+
if (sd_match(
50051+
N, m_And(m_Value(X), m_OneUse(m_Or(m_Value(Y), m_Not(m_Value(Z)))))))
50052+
return DAG.getNode(
50053+
ISD::AND, DL, VT, X,
50054+
DAG.getNOT(DL, DAG.getNode(ISD::AND, DL, VT, DAG.getNOT(DL, Y, VT), Z),
50055+
VT));
5005950056

5006050057
return SDValue();
5006150058
}

llvm/test/CodeGen/X86/pr108731.ll

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -141,54 +141,5 @@ Entry:
141141
ret <16 x i8> %and3
142142
}
143143

144-
define <32 x i8> @test_v32i8(<32 x i8> %w, <32 x i8> %x, <32 x i8> %y, <32 x i8> %z) {
145-
; NOBMI-LABEL: test_v32i8:
146-
; NOBMI: # %bb.0: # %Entry
147-
; NOBMI-NEXT: andps %xmm4, %xmm2
148-
; NOBMI-NEXT: andps %xmm5, %xmm3
149-
; NOBMI-NEXT: andnps %xmm1, %xmm3
150-
; NOBMI-NEXT: andnps %xmm0, %xmm2
151-
; NOBMI-NEXT: andnps %xmm6, %xmm4
152-
; NOBMI-NEXT: andnps %xmm2, %xmm4
153-
; NOBMI-NEXT: andnps %xmm7, %xmm5
154-
; NOBMI-NEXT: andnps %xmm3, %xmm5
155-
; NOBMI-NEXT: movaps %xmm4, %xmm0
156-
; NOBMI-NEXT: movaps %xmm5, %xmm1
157-
; NOBMI-NEXT: retq
158-
;
159-
; BMI-LABEL: test_v32i8:
160-
; BMI: # %bb.0: # %Entry
161-
; BMI-NEXT: vandps %ymm1, %ymm2, %ymm1
162-
; BMI-NEXT: vandnps %ymm0, %ymm1, %ymm0
163-
; BMI-NEXT: vandnps %ymm3, %ymm2, %ymm1
164-
; BMI-NEXT: vandnps %ymm0, %ymm1, %ymm0
165-
; BMI-NEXT: retq
166-
Entry:
167-
%and1 = and <32 x i8> %y, %x
168-
%xor1 = xor <32 x i8> %and1, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
169-
%and2 = and <32 x i8> %xor1, %w
170-
%.not = xor <32 x i8> %z, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
171-
%or1 = or <32 x i8> %.not, %y
172-
%and3 = and <32 x i8> %and2, %or1
173-
ret <32 x i8> %and3
174-
}
175-
176-
; PR112347 - don't fold if we'd be inverting a constant, as demorgan normalisation will invert it back again.
177-
define void @PR112347(ptr %p0, ptr %p1, ptr %p2) {
178-
; CHECK-LABEL: PR112347:
179-
; CHECK: # %bb.0:
180-
; CHECK-NEXT: movl (%rdi), %eax
181-
; CHECK-NEXT: notl %eax
182-
; CHECK-NEXT: orl $-16777204, %eax # imm = 0xFF00000C
183-
; CHECK-NEXT: andl (%rsi), %eax
184-
; CHECK-NEXT: movl %eax, (%rdx)
185-
; CHECK-NEXT: retq
186-
%load0 = load i32, ptr %p0, align 1
187-
%load1 = load i32, ptr %p1, align 4
188-
%not = xor i32 %load0, -1
189-
%top = or i32 %not, -16777204
190-
%mask = and i32 %load1, %top
191-
store i32 %mask, ptr %p2, align 4
192-
ret void
193-
}
194-
144+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
145+
; CHECK: {{.*}}

0 commit comments

Comments
 (0)