diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 4e90c1d5b9e1f..1cfcd3ffbd664 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -21889,6 +21889,10 @@ bool BoUpSLP::collectValuesToDemote( return TryProcessInstruction(BitWidth); case Instruction::ZExt: case Instruction::SExt: + if (E.UserTreeIndex.UserTE && E.UserTreeIndex.UserTE->hasState() && + E.UserTreeIndex.UserTE->getOpcode() == Instruction::BitCast && + E.UserTreeIndex.UserTE->getMainOp()->getType()->isFPOrFPVectorTy()) + return false; IsProfitableToDemote = true; return TryProcessInstruction(BitWidth); diff --git a/llvm/test/Transforms/SLPVectorizer/X86/parent-bitcast-with-fp.ll b/llvm/test/Transforms/SLPVectorizer/X86/parent-bitcast-with-fp.ll new file mode 100644 index 0000000000000..a2f6b900d73cd --- /dev/null +++ b/llvm/test/Transforms/SLPVectorizer/X86/parent-bitcast-with-fp.ll @@ -0,0 +1,36 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 +; RUN: opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s + +define i1 @test(i32 %0) { +; CHECK-LABEL: define i1 @test( +; CHECK-SAME: i32 [[TMP0:%.*]]) { +; CHECK-NEXT: [[ENTRY:.*:]] +; CHECK-NEXT: [[CONV22_I_I:%.*]] = sext i32 [[TMP0]] to i64 +; CHECK-NEXT: [[TMP1:%.*]] = bitcast i64 [[CONV22_I_I]] to double +; CHECK-NEXT: [[TMP2:%.*]] = fadd double [[TMP1]], 0.000000e+00 +; CHECK-NEXT: [[ADD_I_I_I:%.*]] = select i1 false, double 0.000000e+00, double [[TMP2]] +; CHECK-NEXT: [[TMP3:%.*]] = bitcast double [[ADD_I_I_I]] to i64 +; CHECK-NEXT: [[CMP3998_I_I:%.*]] = icmp ne i64 [[TMP3]], [[CONV22_I_I]] +; CHECK-NEXT: [[CONV22_1_I_I:%.*]] = sext i32 0 to i64 +; CHECK-NEXT: [[TMP4:%.*]] = bitcast i64 [[CONV22_1_I_I]] to double +; CHECK-NEXT: [[TMP5:%.*]] = fadd double [[TMP4]], 0.000000e+00 +; CHECK-NEXT: [[ADD_I_1_I_I:%.*]] = select i1 false, double 0.000000e+00, double [[TMP5]] +; CHECK-NEXT: [[TMP6:%.*]] = bitcast double [[ADD_I_1_I_I]] to i64 +; CHECK-NEXT: [[CMP3998_1_I_I:%.*]] = icmp ne i64 [[TMP6]], [[CONV22_1_I_I]] +; CHECK-NEXT: ret i1 [[CMP3998_1_I_I]] +; +entry: + %conv22.i.i = sext i32 %0 to i64 + %1 = bitcast i64 %conv22.i.i to double + %2 = fadd double %1, 0.000000e+00 + %add.i.i.i = select i1 false, double 0.000000e+00, double %2 + %3 = bitcast double %add.i.i.i to i64 + %cmp3998.i.i = icmp ne i64 %3, %conv22.i.i + %conv22.1.i.i = sext i32 0 to i64 + %4 = bitcast i64 %conv22.1.i.i to double + %5 = fadd double %4, 0.000000e+00 + %add.i.1.i.i = select i1 false, double 0.000000e+00, double %5 + %6 = bitcast double %add.i.1.i.i to i64 + %cmp3998.1.i.i = icmp ne i64 %6, %conv22.1.i.i + ret i1 %cmp3998.1.i.i +}