Skip to content

Commit 5b06de7

Browse files
committed
[X86] Add isLogicOp helper to match ISD::AND/OR/XOR and X86ISD::ANDNP
We could easily support the X86ISD 'float' variants of the logic ops as well, but we don't have good test coverage at the moment (they're mainly for SSE1 targets).
1 parent 346f499 commit 5b06de7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2631,6 +2631,11 @@ bool X86::mayFoldIntoZeroExtend(SDValue Op) {
26312631
return false;
26322632
}
26332633

2634+
static bool isLogicOp(unsigned Opcode) {
2635+
// TODO: Add support for X86ISD::FAND/FOR/FXOR/FANDN with test coverage.
2636+
return ISD::isBitwiseLogicOp(Opcode) || X86ISD::ANDNP == Opcode;
2637+
}
2638+
26342639
static bool isTargetShuffle(unsigned Opcode) {
26352640
switch(Opcode) {
26362641
default: return false;
@@ -39975,8 +39980,7 @@ static SDValue canonicalizeShuffleWithOp(SDValue N, SelectionDAG &DAG,
3997539980
auto IsSafeToMoveShuffle = [ShuffleVT](SDValue Op, unsigned BinOp) {
3997639981
// Ensure we only shuffle whole vector src elements, unless its a logical
3997739982
// binops where we can more aggressively move shuffles from dst to src.
39978-
return BinOp == ISD::AND || BinOp == ISD::OR || BinOp == ISD::XOR ||
39979-
BinOp == X86ISD::ANDNP ||
39983+
return isLogicOp(BinOp) ||
3998039984
(Op.getScalarValueSizeInBits() <= ShuffleVT.getScalarSizeInBits());
3998139985
};
3998239986

0 commit comments

Comments
 (0)