Skip to content

Commit

Permalink
ValueTracking: Teach isKnownNeverInfinity about arithmetic.fence
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenm committed Dec 5, 2022
1 parent 7224cff commit dac496f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions llvm/lib/Analysis/ValueTracking.cpp
Expand Up @@ -3793,6 +3793,7 @@ bool llvm::isKnownNeverInfinity(const Value *V, const TargetLibraryInfo *TLI,
case Intrinsic::fabs:
case Intrinsic::canonicalize:
case Intrinsic::copysign:
case Intrinsic::arithmetic_fence:
return isKnownNeverInfinity(Inst->getOperand(0), TLI, Depth + 1);
default:
break;
Expand Down
23 changes: 23 additions & 0 deletions llvm/test/Transforms/InstSimplify/floating-point-compare.ll
Expand Up @@ -1347,3 +1347,26 @@ define i1 @isNotKnownNeverInfinity_copysign(double %x, double %sign) {
%r = fcmp une double %e, 0x7ff0000000000000
ret i1 %r
}

define i1 @isKnownNeverInfinity_arithmetic_fence(double %x) {
; CHECK-LABEL: @isKnownNeverInfinity_arithmetic_fence(
; CHECK-NEXT: ret i1 true
;
%a = fadd ninf double %x, 1.0
%e = call double @llvm.arithmetic.fence.f64(double %a)
%r = fcmp une double %e, 0x7ff0000000000000
ret i1 %r
}

define i1 @isNotKnownNeverInfinity_arithmetic_fence(double %x) {
; CHECK-LABEL: @isNotKnownNeverInfinity_arithmetic_fence(
; CHECK-NEXT: [[E:%.*]] = call double @llvm.arithmetic.fence.f64(double [[X:%.*]])
; CHECK-NEXT: [[R:%.*]] = fcmp une double [[E]], 0x7FF0000000000000
; CHECK-NEXT: ret i1 [[R]]
;
%e = call double @llvm.arithmetic.fence.f64(double %x)
%r = fcmp une double %e, 0x7ff0000000000000
ret i1 %r
}

declare double @llvm.arithmetic.fence.f64(double)

0 comments on commit dac496f

Please sign in to comment.