diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index c28584cc14991..a85ed96e11158 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -2860,12 +2860,13 @@ bool X86::mayFoldIntoZeroExtend(SDValue Op) { } // Return true if its cheap to bitcast this to a vector type. -static bool mayFoldIntoVector(SDValue Op, const X86Subtarget &Subtarget) { +static bool mayFoldIntoVector(SDValue Op, const X86Subtarget &Subtarget, + bool AssumeSingleUse = false) { if (peekThroughBitcasts(Op).getValueType().isVector()) return true; if (isa(Op) || isa(Op)) return true; - return X86::mayFoldLoad(Op, Subtarget, /*AssumeSingleUse=*/false, + return X86::mayFoldLoad(Op, Subtarget, AssumeSingleUse, /*IgnoreAlignment=*/true); } @@ -23122,12 +23123,9 @@ static SDValue combineVectorSizedSetCCEquality(EVT VT, SDValue X, SDValue Y, return SDValue(); // Don't perform this combine if constructing the vector will be expensive. - auto IsVectorBitCastCheap = [](SDValue X) { - X = peekThroughBitcasts(X); - return isa(X) || X.getValueType().isVector() || - ISD::isNormalLoad(X.getNode()); - }; - if ((!IsVectorBitCastCheap(X) || !IsVectorBitCastCheap(Y)) && + // TODO: Drop AssumeSingleUse = true override. + if ((!mayFoldIntoVector(X, Subtarget, /*AssumeSingleUse=*/true) || + !mayFoldIntoVector(Y, Subtarget, /*AssumeSingleUse=*/true)) && !IsOrXorXorTreeCCZero) return SDValue();