[PATCH] D50081: [ValueTracking] fix maxnum miscompile for cannotBeOrderedLessThanZero (PR37776)
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 2 06:46:44 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338716: [ValueTracking] fix maxnum miscompile for cannotBeOrderedLessThanZero (PR37776) (authored by spatel, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D50081?vs=158316&id=158747#toc
Repository:
rL LLVM
https://reviews.llvm.org/D50081
Files:
llvm/trunk/lib/Analysis/ValueTracking.cpp
llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll
Index: llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll
===================================================================
--- llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll
+++ llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll
@@ -266,13 +266,15 @@
ret i1 %uge
}
-; FIXME: This is wrong.
; PR37776: https://bugs.llvm.org/show_bug.cgi?id=37776
; exp() may return nan, leaving %1 as the unknown result, so we can't simplify.
define i1 @orderedLessZeroMaxNum(float, float) {
; CHECK-LABEL: @orderedLessZeroMaxNum(
-; CHECK-NEXT: ret i1 true
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.exp.f32(float [[TMP0:%.*]])
+; CHECK-NEXT: [[B:%.*]] = call float @llvm.maxnum.f32(float [[A]], float [[TMP1:%.*]])
+; CHECK-NEXT: [[UGE:%.*]] = fcmp uge float [[B]], 0.000000e+00
+; CHECK-NEXT: ret i1 [[UGE]]
;
%a = call float @llvm.exp.f32(float %0)
%b = call float @llvm.maxnum.f32(float %a, float %1)
Index: llvm/trunk/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp
@@ -2817,10 +2817,13 @@
default:
break;
case Intrinsic::maxnum:
- return cannotBeOrderedLessThanZeroImpl(I->getOperand(0), TLI, SignBitOnly,
- Depth + 1) ||
- cannotBeOrderedLessThanZeroImpl(I->getOperand(1), TLI, SignBitOnly,
- Depth + 1);
+ return (isKnownNeverNaN(I->getOperand(0)) &&
+ cannotBeOrderedLessThanZeroImpl(I->getOperand(0), TLI,
+ SignBitOnly, Depth + 1)) ||
+ (isKnownNeverNaN(I->getOperand(1)) &&
+ cannotBeOrderedLessThanZeroImpl(I->getOperand(1), TLI,
+ SignBitOnly, Depth + 1));
+
case Intrinsic::minnum:
return cannotBeOrderedLessThanZeroImpl(I->getOperand(0), TLI, SignBitOnly,
Depth + 1) &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50081.158747.patch
Type: text/x-patch
Size: 2112 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180802/6e50df13/attachment.bin>
More information about the llvm-commits
mailing list