[ValueTracking] Bail out on x86_fp80 when computing fpclass with know… · llvm/llvm-project@0e96713 (original) (raw)
File tree
2 files changed
lines changed
- test/Transforms/InstSimplify
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -6135,13 +6135,14 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts, | ||
6135 | 6135 | else if (Bits.isNegative()) |
6136 | 6136 | Known.signBitMustBeOne(); |
6137 | 6137 | |
6138 | -if (Ty->isIEEE()) { | |
6138 | +if (Ty->isIEEELikeFPTy()) { | |
6139 | 6139 | // IEEE floats are NaN when all bits of the exponent plus at least one of |
6140 | 6140 | // the fraction bits are 1. This means: |
6141 | 6141 | // - If we assume unknown bits are 0 and the value is NaN, it will |
6142 | 6142 | // always be NaN |
6143 | 6143 | // - If we assume unknown bits are 1 and the value is not NaN, it can |
6144 | 6144 | // never be NaN |
6145 | +// Note: They do not hold for x86_fp80 format. | |
6145 | 6146 | if (APFloat(Ty->getFltSemantics(), Bits.One).isNaN()) |
6146 | 6147 | Known.KnownFPClasses = fcNan; |
6147 | 6148 | else if (!APFloat(Ty->getFltSemantics(), ~Bits.Zero).isNaN()) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -16,3 +16,20 @@ define i1 @poison2(float %x) { | ||
16 | 16 | %v = fcmp ueq float %x, poison |
17 | 17 | ret i1 %v |
18 | 18 | } |
19 | + | |
20 | +define i1 @pr130408(x86_fp80 %x) { | |
21 | +; CHECK-LABEL: @pr130408( | |
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]] | |
28 | +; | |
29 | +%bits = bitcast x86_fp80 %x to i80 | |
30 | +%masked = and i80 %bits, -604444463063240877801473 | |
31 | +%or = or i80 %masked, 302194561415509874573312 | |
32 | +%fp = bitcast i80 %or to x86_fp80 | |
33 | +%res = fcmp uno x86_fp80 %fp, 0xK00000000000000000000 | |
34 | +ret i1 %res | |
35 | +} |