Skip to content

Commit 47c7bb1

Browse files
committed
[ValueTracking] Bail out on x86_fp80 when computing fpclass with knownbits
1 parent d037089 commit 47c7bb1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6208,13 +6208,14 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
62086208
else if (Bits.isNegative())
62096209
Known.signBitMustBeOne();
62106210

6211-
if (Ty->isIEEE()) {
6211+
if (Ty->isIEEELikeFPTy()) {
62126212
// IEEE floats are NaN when all bits of the exponent plus at least one of
62136213
// the fraction bits are 1. This means:
62146214
// - If we assume unknown bits are 0 and the value is NaN, it will
62156215
// always be NaN
62166216
// - If we assume unknown bits are 1 and the value is not NaN, it can
62176217
// never be NaN
6218+
// Note: They do not hold for x86_fp80 format.
62186219
if (APFloat(Ty->getFltSemantics(), Bits.One).isNaN())
62196220
Known.KnownFPClasses = fcNan;
62206221
else if (!APFloat(Ty->getFltSemantics(), ~Bits.Zero).isNaN())

llvm/test/Transforms/InstSimplify/fcmp.ll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ define i1 @poison2(float %x) {
1919

2020
define i1 @pr130408(x86_fp80 %x) {
2121
; CHECK-LABEL: @pr130408(
22-
; CHECK-NEXT: ret i1 true
22+
; CHECK-NEXT: [[BITS:%.*]] = bitcast x86_fp80 [[X:%.*]] to i80
23+
; CHECK-NEXT: [[MASKED:%.*]] = and i80 [[BITS]], -604444463063240877801473
24+
; CHECK-NEXT: [[OR:%.*]] = or i80 [[MASKED]], 302194561415509874573312
25+
; CHECK-NEXT: [[FP:%.*]] = bitcast i80 [[OR]] to x86_fp80
26+
; CHECK-NEXT: [[RES:%.*]] = fcmp uno x86_fp80 [[FP]], 0xK00000000000000000000
27+
; CHECK-NEXT: ret i1 [[RES]]
2328
;
2429
%bits = bitcast x86_fp80 %x to i80
2530
%masked = and i80 %bits, -604444463063240877801473

0 commit comments

Comments
 (0)