[PATCH] D147939: ValueTracking: Handle fptrunc in computeKnownFPClass
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 13 15:49:11 PDT 2023
arsenm updated this revision to Diff 513378.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147939/new/
https://reviews.llvm.org/D147939
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/Attributor/nofpclass-fptrunc.ll
Index: llvm/test/Transforms/Attributor/nofpclass-fptrunc.ll
===================================================================
--- llvm/test/Transforms/Attributor/nofpclass-fptrunc.ll
+++ llvm/test/Transforms/Attributor/nofpclass-fptrunc.ll
@@ -12,7 +12,7 @@
}
define float @ret_fptrunc_nonan(double nofpclass(nan) %arg0) {
-; CHECK-LABEL: define float @ret_fptrunc_nonan
+; CHECK-LABEL: define nofpclass(nan) float @ret_fptrunc_nonan
; CHECK-SAME: (double nofpclass(nan) [[ARG0:%.*]]) #[[ATTR0]] {
; CHECK-NEXT: [[EXT:%.*]] = fptrunc double [[ARG0]] to float
; CHECK-NEXT: ret float [[EXT]]
@@ -102,7 +102,7 @@
}
define float @ret_fptrunc_nonan_noinf(double nofpclass(nan inf) %arg0) {
-; CHECK-LABEL: define float @ret_fptrunc_nonan_noinf
+; CHECK-LABEL: define nofpclass(nan) float @ret_fptrunc_nonan_noinf
; CHECK-SAME: (double nofpclass(nan inf) [[ARG0:%.*]]) #[[ATTR0]] {
; CHECK-NEXT: [[EXT:%.*]] = fptrunc double [[ARG0]] to float
; CHECK-NEXT: ret float [[EXT]]
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -4641,6 +4641,19 @@
Known.SignBit = std::nullopt;
break;
}
+ case Instruction::FPTrunc: {
+ if ((InterestedClasses & fcNan) == fcNone)
+ break;
+
+ KnownFPClass KnownSrc;
+ computeKnownFPClass(Op->getOperand(0), DemandedElts,
+ InterestedClasses, KnownSrc, Depth + 1, Q, TLI);
+ if (KnownSrc.isKnownNeverNaN())
+ Known.knownNot(fcNan);
+
+ // Infinity needs a range check.
+ break;
+ }
case Instruction::SIToFP:
case Instruction::UIToFP: {
// Cannot produce nan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147939.513378.patch
Type: text/x-patch
Size: 1733 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230413/7035cd27/attachment.bin>
More information about the llvm-commits
mailing list