Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4121,6 +4121,25 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
Known.One.clearLowBits(LogOfAlign);
break;
}
case ISD::AssertNoFPClass: {
Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does SDAG's version of computeKnownBits also work for floating-point values?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly just through bitcasts to wrapped integer logic etc. But X86 does successfully use it for some of its FP node types


FPClassTest NoFPClass =
static_cast<FPClassTest>(Op.getConstantOperandVal(1));
const FPClassTest NegativeTestMask = fcNan | fcNegative;
if ((NoFPClass & NegativeTestMask) == NegativeTestMask) {
// Cannot be negative.
Known.makeNonNegative();
}

const FPClassTest PositiveTestMask = fcNan | fcPositive;
if ((NoFPClass & PositiveTestMask) == PositiveTestMask) {
// Cannot be positive.
Known.makeNegative();
}

break;
}
case ISD::FGETSIGN:
// All bits are zero except the low bit.
Known.Zero.setBitsFrom(1);
Expand Down
2 changes: 0 additions & 2 deletions llvm/test/CodeGen/AMDGPU/compute-known-bits-nofpclass.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ define i32 @known_positive(float nofpclass(nan ninf nzero nsub nnorm) %signbit.z
; CHECK-LABEL: known_positive:
; CHECK: ; %bb.0:
; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; CHECK-NEXT: v_and_b32_e32 v0, 0x7fffffff, v0
; CHECK-NEXT: s_setpc_b64 s[30:31]
%cast = bitcast float %signbit.zero to i32
%and = and i32 %cast, 2147483647
Expand All @@ -27,7 +26,6 @@ define i32 @known_negative(float nofpclass(nan pinf pzero psub pnorm) %signbit.o
; CHECK-LABEL: known_negative:
; CHECK: ; %bb.0:
; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; CHECK-NEXT: v_or_b32_e32 v0, 0x80000000, v0
; CHECK-NEXT: s_setpc_b64 s[30:31]
%cast = bitcast float %signbit.one to i32
%or = or i32 %cast, -2147483648
Expand Down