aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp3
-rw-r--r--llvm/test/Transforms/Attributor/nofpclass.ll8
-rw-r--r--llvm/unittests/Analysis/ValueTrackingTest.cpp6
3 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index c25f02b..b8ca38d 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -4627,6 +4627,9 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
case Instruction::UIToFP: {
// Cannot produce nan
Known.knownNot(fcNan);
+
+ // sitofp and uitofp turn into +0.0 for zero.
+ Known.knownNot(fcNegZero);
if (Op->getOpcode() == Instruction::UIToFP)
Known.signBitIsZero();
diff --git a/llvm/test/Transforms/Attributor/nofpclass.ll b/llvm/test/Transforms/Attributor/nofpclass.ll
index 52c9c2e..0ae2de3 100644
--- a/llvm/test/Transforms/Attributor/nofpclass.ll
+++ b/llvm/test/Transforms/Attributor/nofpclass.ll
@@ -694,7 +694,7 @@ define float @uitofp_i32_to_f32(i32 %arg) {
define float @sitofp_i32_to_f32(i32 %arg) {
; CHECK: Function Attrs: nofree norecurse nosync nounwind willreturn memory(none)
-; CHECK-LABEL: define nofpclass(nan inf) float @sitofp_i32_to_f32
+; CHECK-LABEL: define nofpclass(nan inf nzero) float @sitofp_i32_to_f32
; CHECK-SAME: (i32 [[ARG:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: [[CVT:%.*]] = sitofp i32 [[ARG]] to float
; CHECK-NEXT: ret float [[CVT]]
@@ -716,7 +716,7 @@ define <2 x float> @uitofp_v2i32_to_v2f32(<2 x i32> %arg) {
define <2 x float> @sitofp_v2i32_to_v2i32(<2 x i32> %arg) {
; CHECK: Function Attrs: nofree norecurse nosync nounwind willreturn memory(none)
-; CHECK-LABEL: define nofpclass(nan inf) <2 x float> @sitofp_v2i32_to_v2i32
+; CHECK-LABEL: define nofpclass(nan inf nzero) <2 x float> @sitofp_v2i32_to_v2i32
; CHECK-SAME: (<2 x i32> [[ARG:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: [[CVT:%.*]] = sitofp <2 x i32> [[ARG]] to <2 x float>
; CHECK-NEXT: ret <2 x float> [[CVT]]
@@ -738,7 +738,7 @@ define half @uitofp_i17_to_f16(i17 %arg) {
define half @sitofp_i17_to_f16(i17 %arg) {
; CHECK: Function Attrs: nofree norecurse nosync nounwind willreturn memory(none)
-; CHECK-LABEL: define nofpclass(nan) half @sitofp_i17_to_f16
+; CHECK-LABEL: define nofpclass(nan nzero) half @sitofp_i17_to_f16
; CHECK-SAME: (i17 [[ARG:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: [[CVT:%.*]] = sitofp i17 [[ARG]] to half
; CHECK-NEXT: ret half [[CVT]]
@@ -760,7 +760,7 @@ define <2 x half> @uitofp_v2i17_to_v2f16(<2 x i17> %arg) {
define <2 x half> @sitofp_v2i17_to_v2i17(<2 x i17> %arg) {
; CHECK: Function Attrs: nofree norecurse nosync nounwind willreturn memory(none)
-; CHECK-LABEL: define nofpclass(nan) <2 x half> @sitofp_v2i17_to_v2i17
+; CHECK-LABEL: define nofpclass(nan nzero) <2 x half> @sitofp_v2i17_to_v2i17
; CHECK-SAME: (<2 x i17> [[ARG:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: [[CVT:%.*]] = sitofp <2 x i17> [[ARG]] to <2 x half>
; CHECK-NEXT: ret <2 x half> [[CVT]]
diff --git a/llvm/unittests/Analysis/ValueTrackingTest.cpp b/llvm/unittests/Analysis/ValueTrackingTest.cpp
index 9327315..284d799 100644
--- a/llvm/unittests/Analysis/ValueTrackingTest.cpp
+++ b/llvm/unittests/Analysis/ValueTrackingTest.cpp
@@ -1539,9 +1539,9 @@ TEST_F(ComputeKnownFPClassTest, SIToFP) {
" %A3 = sitofp i17 %arg2 to half"
" ret float %A\n"
"}\n");
- expectKnownFPClass(fcFinite, std::nullopt, A);
- expectKnownFPClass(fcFinite, std::nullopt, A2);
- expectKnownFPClass(~fcNan, std::nullopt, A3);
+ expectKnownFPClass(fcFinite & ~fcNegZero, std::nullopt, A);
+ expectKnownFPClass(fcFinite & ~fcNegZero, std::nullopt, A2);
+ expectKnownFPClass(~(fcNan | fcNegZero), std::nullopt, A3);
}
TEST_F(ComputeKnownFPClassTest, FAdd) {