[llvm] r257542 - CannotBeOrderedLessThanZero: add some missing cases
Fiona Glaser via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 12 15:37:30 PST 2016
Author: escha
Date: Tue Jan 12 17:37:30 2016
New Revision: 257542
URL: http://llvm.org/viewvc/llvm-project?rev=257542&view=rev
Log:
CannotBeOrderedLessThanZero: add some missing cases
Modified:
llvm/trunk/lib/Analysis/ValueTracking.cpp
llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll
Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=257542&r1=257541&r2=257542&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Tue Jan 12 17:37:30 2016
@@ -2556,6 +2556,9 @@ bool llvm::CannotBeOrderedLessThanZero(c
switch (I->getOpcode()) {
default: break;
+ // Unsigned integers are always nonnegative.
+ case Instruction::UIToFP:
+ return true;
case Instruction::FMul:
// x*x is always non-negative or a NaN.
if (I->getOperand(0) == I->getOperand(1))
@@ -2566,6 +2569,9 @@ bool llvm::CannotBeOrderedLessThanZero(c
case Instruction::FRem:
return CannotBeOrderedLessThanZero(I->getOperand(0), Depth+1) &&
CannotBeOrderedLessThanZero(I->getOperand(1), Depth+1);
+ case Instruction::Select:
+ return CannotBeOrderedLessThanZero(I->getOperand(1), Depth+1) &&
+ CannotBeOrderedLessThanZero(I->getOperand(2), Depth+1);
case Instruction::FPExt:
case Instruction::FPTrunc:
// Widening/narrowing never change sign.
@@ -2574,6 +2580,12 @@ bool llvm::CannotBeOrderedLessThanZero(c
if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(I))
switch (II->getIntrinsicID()) {
default: break;
+ case Intrinsic::maxnum:
+ return CannotBeOrderedLessThanZero(I->getOperand(0), Depth+1) ||
+ CannotBeOrderedLessThanZero(I->getOperand(1), Depth+1);
+ case Intrinsic::minnum:
+ return CannotBeOrderedLessThanZero(I->getOperand(0), Depth+1) &&
+ CannotBeOrderedLessThanZero(I->getOperand(1), Depth+1);
case Intrinsic::exp:
case Intrinsic::exp2:
case Intrinsic::fabs:
Modified: llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll?rev=257542&r1=257541&r2=257542&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll Tue Jan 12 17:37:30 2016
@@ -8,6 +8,8 @@ declare float @llvm.fabs.f32(float)
declare float @llvm.sqrt.f32(float)
declare double @llvm.powi.f64(double,i32)
declare float @llvm.exp.f32(float)
+declare float @llvm.minnum.f32(float, float)
+declare float @llvm.maxnum.f32(float, float)
declare double @llvm.exp2.f64(double)
declare float @llvm.fma.f32(float,float,float)
@@ -58,6 +60,45 @@ define i1 @orderedLessZeroPowi(double,do
ret i1 %olt
}
+; CHECK-LABEL: @orderedLessZeroUIToFP(
+define i1 @orderedLessZeroUIToFP(i32) {
+ %a = uitofp i32 %0 to float
+ %uge = fcmp uge float %a, 0.000000e+00
+; CHECK: ret i1 true
+ ret i1 %uge
+}
+
+; CHECK-LABEL: @orderedLessZeroSelect(
+define i1 @orderedLessZeroSelect(float, float) {
+ %a = call float @llvm.exp.f32(float %0)
+ %b = call float @llvm.fabs.f32(float %1)
+ %c = fcmp olt float %0, %1
+ %d = select i1 %c, float %a, float %b
+ %e = fadd float %d, 1.0
+ %uge = fcmp uge float %e, 0.000000e+00
+; CHECK: ret i1 true
+ ret i1 %uge
+}
+
+; CHECK-LABEL: @orderedLessZeroMinNum(
+define i1 @orderedLessZeroMinNum(float, float) {
+ %a = call float @llvm.exp.f32(float %0)
+ %b = call float @llvm.fabs.f32(float %1)
+ %c = call float @llvm.minnum.f32(float %a, float %b)
+ %uge = fcmp uge float %c, 0.000000e+00
+; CHECK: ret i1 true
+ ret i1 %uge
+}
+
+; CHECK-LABEL: @orderedLessZeroMaxNum(
+define i1 @orderedLessZeroMaxNum(float, float) {
+ %a = call float @llvm.exp.f32(float %0)
+ %b = call float @llvm.maxnum.f32(float %a, float %1)
+ %uge = fcmp uge float %b, 0.000000e+00
+; CHECK: ret i1 true
+ ret i1 %uge
+}
+
define i1 @nonans1(double %in1, double %in2) {
%cmp = fcmp nnan uno double %in1, %in2
ret i1 %cmp
More information about the llvm-commits
mailing list