diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2768,23 +2768,28 @@ // The sign-bit is always the most significant bit in those types. const APInt *C; bool TrueIfSigned; - if (!BCSrcOp->getType()->isPPC_FP128Ty() && match(Op1, m_APInt(C)) && - Bitcast->hasOneUse() && isSignBitCheck(Pred, *C, TrueIfSigned)) { + if (match(Op1, m_APInt(C)) && Bitcast->hasOneUse() && + isSignBitCheck(Pred, *C, TrueIfSigned)) { if (match(BCSrcOp, m_FPExt(m_Value(X))) || match(BCSrcOp, m_FPTrunc(m_Value(X)))) { // (bitcast (fpext/fptrunc X)) to iX) < 0 --> (bitcast X to iY) < 0 // (bitcast (fpext/fptrunc X)) to iX) > -1 --> (bitcast X to iY) > -1 Type *XType = X->getType(); - Type *NewType = Builder.getIntNTy(XType->getScalarSizeInBits()); - if (auto *XVTy = dyn_cast(XType)) - NewType = VectorType::get(NewType, XVTy->getNumElements()); - Value *NewBitcast = Builder.CreateBitCast(X, NewType); - if (TrueIfSigned) - return new ICmpInst(ICmpInst::ICMP_SLT, NewBitcast, - ConstantInt::getNullValue(NewType)); - else - return new ICmpInst(ICmpInst::ICMP_SGT, NewBitcast, - ConstantInt::getAllOnesValue(NewType)); + + // We can't currently handle Power style floating point operations here. + if (!(XType->isPPC_FP128Ty() || BCSrcOp->getType()->isPPC_FP128Ty())) { + + Type *NewType = Builder.getIntNTy(XType->getScalarSizeInBits()); + if (auto *XVTy = dyn_cast(XType)) + NewType = VectorType::get(NewType, XVTy->getNumElements()); + Value *NewBitcast = Builder.CreateBitCast(X, NewType); + if (TrueIfSigned) + return new ICmpInst(ICmpInst::ICMP_SLT, NewBitcast, + ConstantInt::getNullValue(NewType)); + else + return new ICmpInst(ICmpInst::ICMP_SGT, NewBitcast, + ConstantInt::getAllOnesValue(NewType)); + } } } } diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -3713,8 +3713,9 @@ define i1 @signbit_bitcast_fptrunc_ppc_fp128(ppc_fp128 %x) { ; CHECK-LABEL: @signbit_bitcast_fptrunc_ppc_fp128( -; CHECK-NEXT: [[TMP1:%.*]] = bitcast ppc_fp128 [[X:%.*]] to i128 -; CHECK-NEXT: [[S4:%.*]] = icmp slt i128 [[TMP1]], 0 +; CHECK-NEXT: [[S2:%.*]] = fptrunc ppc_fp128 [[X:%.*]] to float +; CHECK-NEXT: [[S3:%.*]] = bitcast float [[S2]] to i32 +; CHECK-NEXT: [[S4:%.*]] = icmp slt i32 [[S3]], 0 ; CHECK-NEXT: ret i1 [[S4]] ; %s2 = fptrunc ppc_fp128 %x to float