[PATCH] D77911: Exclude bitcast and ext/trunc signbit optimization on ppc_fp128
Eric Christopher via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 10 17:48:14 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG45dca043957a: Exclude bitcast and ext/trunc signbit optimization on ppc_fp128 (authored by echristo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77911/new/
https://reviews.llvm.org/D77911
Files:
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp.ll
Index: llvm/test/Transforms/InstCombine/icmp.ll
===================================================================
--- llvm/test/Transforms/InstCombine/icmp.ll
+++ 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
Index: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ 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<VectorType>(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<VectorType>(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));
+ }
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77911.256723.patch
Type: text/x-patch
Size: 3031 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200411/5f18c923/attachment-0001.bin>
More information about the llvm-commits
mailing list