// FIXME: it tries to fix a problem with MSVC buildbots.
TargetTransformInfo *TTI = this->TTI;
auto AdjustExtractsCost = [=](InstructionCost &Cost) {
+ // If the resulting type is scalarized, do not adjust the cost.
+ unsigned VecNumParts = TTI->getNumberOfParts(VecTy);
+ if (VecNumParts == VecTy->getNumElements())
+ return;
DenseMap<Value *, int> ExtractVectorsTys;
SmallPtrSet<Value *, 4> CheckedExtracts;
for (auto *V : VL) {
if (!EEIdx)
continue;
unsigned Idx = *EEIdx;
- if (TTI->getNumberOfParts(VecTy) !=
- TTI->getNumberOfParts(EE->getVectorOperandType())) {
+ if (VecNumParts != TTI->getNumberOfParts(EE->getVectorOperandType())) {
auto It =
ExtractVectorsTys.try_emplace(EE->getVectorOperand(), Idx).first;
It->getSecond() = std::min<int>(It->second, Idx);
unsigned NumElts = VecTy->getNumElements();
if (Data.second % NumElts == 0)
continue;
- if (TTI->getNumberOfParts(EEVTy) > TTI->getNumberOfParts(VecTy)) {
+ if (TTI->getNumberOfParts(EEVTy) > VecNumParts) {
unsigned Idx = (Data.second / NumElts) * NumElts;
unsigned EENumElts = EEVTy->getNumElements();
if (Idx + NumElts <= EENumElts) {
--- /dev/null
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -S < %s | FileCheck %s
+
+define void @test() {
+; CHECK-LABEL: @test(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TMP0:%.*]] = extractelement <8 x half> zeroinitializer, i64 1
+; CHECK-NEXT: [[TOBOOL:%.*]] = fcmp une half [[TMP0]], 0xH0000
+; CHECK-NEXT: [[TMP1:%.*]] = extractelement <8 x half> zeroinitializer, i64 1
+; CHECK-NEXT: [[TOBOOL3:%.*]] = fcmp une half [[TMP1]], 0xH0000
+; CHECK-NEXT: ret void
+;
+entry:
+ %0 = extractelement <8 x half> zeroinitializer, i64 1
+ %tobool = fcmp une half %0, 0xH0000
+ %1 = extractelement <8 x half> zeroinitializer, i64 1
+ %tobool3 = fcmp une half %1, 0xH0000
+ ret void
+}