[PATCH] D77642: [InstCombine] exclude bitcast of ppc_fp128 in icmp signbit fold
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 7 05:23:20 PDT 2020
spatel created this revision.
spatel added reviewers: echristo, kbarton.
Herald added subscribers: hiraditya, mcrosier.
Based on the post-commit comments for rG0f56bbc <https://reviews.llvm.org/rG0f56bbc1a5b2ddc881d1c55c9024b9c473dac6f0>, there might be a problem with this transform:
(bitcast (fpext/fptrunc X)) to iX) < 0 --> (bitcast X to iY) < 0
...and the ppc_fp128 data type, so conservatively bypass if we are bitcasting a ppc_fp128.
https://reviews.llvm.org/D77642
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
@@ -3700,8 +3700,9 @@
define i1 @signbit_bitcast_fpext_ppc_fp128(float %x) {
; CHECK-LABEL: @signbit_bitcast_fpext_ppc_fp128(
-; CHECK-NEXT: [[TMP1:%.*]] = bitcast float [[X:%.*]] to i32
-; CHECK-NEXT: [[S4:%.*]] = icmp slt i32 [[TMP1]], 0
+; CHECK-NEXT: [[S2:%.*]] = fpext float [[X:%.*]] to ppc_fp128
+; CHECK-NEXT: [[S3:%.*]] = bitcast ppc_fp128 [[S2]] to i128
+; CHECK-NEXT: [[S4:%.*]] = icmp slt i128 [[S3]], 0
; CHECK-NEXT: ret i1 [[S4]]
;
%s2 = fpext float %x to ppc_fp128
Index: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -2766,8 +2766,8 @@
// the FP cast because the FP cast does not change the sign-bit.
const APInt *C;
bool TrueIfSigned;
- if (match(Op1, m_APInt(C)) && Bitcast->hasOneUse() &&
- isSignBitCheck(Pred, *C, TrueIfSigned)) {
+ if (!BCSrcOp->getType()->isPPC_FP128Ty() && 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77642.255649.patch
Type: text/x-patch
Size: 1540 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200407/47d935ea/attachment-0001.bin>
More information about the llvm-commits
mailing list