diff options
Diffstat (limited to 'llvm/lib/Target/X86')
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 4c18c5a84c2..67f98d8ee72 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -37026,9 +37026,13 @@ static bool isHorizontalBinOp(SDValue &LHS, SDValue &RHS, bool IsCommutative) { continue; // The low half of the 128-bit result must choose from A. - // The high half of the 128-bit result must choose from B. + // The high half of the 128-bit result must choose from B, + // unless B is undef. In that case, we are always choosing from A. + // TODO: Using a horizontal op on a single input is likely worse for + // performance on many CPUs, so this should be limited here or reversed + // in a later pass. unsigned NumEltsPer64BitChunk = NumEltsPer128BitChunk / 2; - unsigned Src = i >= NumEltsPer64BitChunk; + unsigned Src = B.getNode() ? i >= NumEltsPer64BitChunk : 0; // Check that successive elements are being operated on. If not, this is // not a horizontal operation. |

