Skip to content

Commit

Permalink
Merged master:0d2fe90063e9 into amd-gfx:43b9ac8878b2
Browse files Browse the repository at this point in the history
Local branch amd-gfx 43b9ac8 Merged master:4d90ff59ac45 into amd-gfx:8832016e5a77
Remote branch master 0d2fe90 AMDGPU/GlobalISel: Use more accurate legality rules for merge/unmerge
  • Loading branch information
Sw authored and Sw committed Aug 25, 2020
2 parents 43b9ac8 + 0d2fe90 commit 1fe58ed
Show file tree
Hide file tree
Showing 84 changed files with 3,517 additions and 2,397 deletions.
65 changes: 63 additions & 2 deletions compiler-rt/test/builtins/Unit/divdf3_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,72 @@ int test__divdf3(double a, double b, uint64_t expected)

int main()
{
// Returned NaNs are assumed to be qNaN by default

// qNaN / any = qNaN
if (test__divdf3(makeQNaN64(), 3., UINT64_C(0x7ff8000000000000)))
return 1;
// NaN / any = NaN
if (test__divdf3(makeNaN64(UINT64_C(0x123)), 3., UINT64_C(0x7ff8000000000000)))
return 1;
// any / qNaN = qNaN
if (test__divdf3(3., makeQNaN64(), UINT64_C(0x7ff8000000000000)))
return 1;
// any / NaN = NaN
if (test__divdf3(3., makeNaN64(UINT64_C(0x123)), UINT64_C(0x7ff8000000000000)))
return 1;

// +Inf / positive = +Inf
if (test__divdf3(makeInf64(), 3., UINT64_C(0x7ff0000000000000)))
return 1;
// +Inf / negative = -Inf
if (test__divdf3(makeInf64(), -3., UINT64_C(0xfff0000000000000)))
return 1;
// -Inf / positive = -Inf
if (test__divdf3(makeNegativeInf64(), 3., UINT64_C(0xfff0000000000000)))
return 1;
// -Inf / negative = +Inf
if (test__divdf3(makeNegativeInf64(), -3., UINT64_C(0x7ff0000000000000)))
return 1;

// Inf / Inf = NaN
if (test__divdf3(makeInf64(), makeInf64(), UINT64_C(0x7ff8000000000000)))
return 1;
// 0.0 / 0.0 = NaN
if (test__divdf3(+0x0.0p+0, +0x0.0p+0, UINT64_C(0x7ff8000000000000)))
return 1;
// +0.0 / +Inf = +0.0
if (test__divdf3(+0x0.0p+0, makeInf64(), UINT64_C(0x0)))
return 1;
// +Inf / +0.0 = +Inf
if (test__divdf3(makeInf64(), +0x0.0p+0, UINT64_C(0x7ff0000000000000)))
return 1;

// positive / +0.0 = +Inf
if (test__divdf3(+1.0, +0x0.0p+0, UINT64_C(0x7ff0000000000000)))
return 1;
// positive / -0.0 = -Inf
if (test__divdf3(+1.0, -0x0.0p+0, UINT64_C(0xfff0000000000000)))
return 1;
// negative / +0.0 = -Inf
if (test__divdf3(-1.0, +0x0.0p+0, UINT64_C(0xfff0000000000000)))
return 1;
// negative / -0.0 = +Inf
if (test__divdf3(-1.0, -0x0.0p+0, UINT64_C(0x7ff0000000000000)))
return 1;

// 1/3
if (test__divdf3(1., 3., 0x3fd5555555555555ULL))
if (test__divdf3(1., 3., UINT64_C(0x3fd5555555555555)))
return 1;
// smallest normal result
if (test__divdf3(4.450147717014403e-308, 2., 0x10000000000000ULL))
if (test__divdf3(0x1.0p-1021, 2., UINT64_C(0x10000000000000)))
return 1;

// divisor is exactly 1.0
if (test__divdf3(0x1.0p+0, 0x1.0p+0, UINT64_C(0x3ff0000000000000)))
return 1;
// divisor is truncated to exactly 1.0 in UQ1.31
if (test__divdf3(0x1.0p+0, 0x1.00000001p+0, UINT64_C(0x3fefffffffe00000)))
return 1;

return 0;
Expand Down
65 changes: 63 additions & 2 deletions compiler-rt/test/builtins/Unit/divsf3_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,72 @@ int test__divsf3(float a, float b, uint32_t expected)

int main()
{
// Returned NaNs are assumed to be qNaN by default

// qNaN / any = qNaN
if (test__divsf3(makeQNaN32(), 3.F, UINT32_C(0x7fc00000)))
return 1;
// NaN / any = NaN
if (test__divsf3(makeNaN32(UINT32_C(0x123)), 3.F, UINT32_C(0x7fc00000)))
return 1;
// any / qNaN = qNaN
if (test__divsf3(3.F, makeQNaN32(), UINT32_C(0x7fc00000)))
return 1;
// any / NaN = NaN
if (test__divsf3(3.F, makeNaN32(UINT32_C(0x123)), UINT32_C(0x7fc00000)))
return 1;

// +Inf / positive = +Inf
if (test__divsf3(makeInf32(), 3.F, UINT32_C(0x7f800000)))
return 1;
// +Inf / negative = -Inf
if (test__divsf3(makeInf32(), -3.F, UINT32_C(0xff800000)))
return 1;
// -Inf / positive = -Inf
if (test__divsf3(makeNegativeInf32(), 3.F, UINT32_C(0xff800000)))
return 1;
// -Inf / negative = +Inf
if (test__divsf3(makeNegativeInf32(), -3.F, UINT32_C(0x7f800000)))
return 1;

// Inf / Inf = NaN
if (test__divsf3(makeInf32(), makeInf32(), UINT32_C(0x7fc00000)))
return 1;
// 0.0 / 0.0 = NaN
if (test__divsf3(+0x0.0p+0F, +0x0.0p+0F, UINT32_C(0x7fc00000)))
return 1;
// +0.0 / +Inf = +0.0
if (test__divsf3(+0x0.0p+0F, makeInf32(), UINT32_C(0x0)))
return 1;
// +Inf / +0.0 = +Inf
if (test__divsf3(makeInf32(), +0x0.0p+0F, UINT32_C(0x7f800000)))
return 1;

// positive / +0.0 = +Inf
if (test__divsf3(+1.F, +0x0.0p+0F, UINT32_C(0x7f800000)))
return 1;
// positive / -0.0 = -Inf
if (test__divsf3(+1.F, -0x0.0p+0F, UINT32_C(0xff800000)))
return 1;
// negative / +0.0 = -Inf
if (test__divsf3(-1.F, +0x0.0p+0F, UINT32_C(0xff800000)))
return 1;
// negative / -0.0 = +Inf
if (test__divsf3(-1.F, -0x0.0p+0F, UINT32_C(0x7f800000)))
return 1;

// 1/3
if (test__divsf3(1.f, 3.f, 0x3EAAAAABU))
if (test__divsf3(1.F, 3.F, UINT32_C(0x3eaaaaab)))
return 1;
// smallest normal result
if (test__divsf3(2.3509887e-38, 2., 0x00800000U))
if (test__divsf3(0x1.0p-125F, 2.F, UINT32_C(0x00800000)))
return 1;

// divisor is exactly 1.0
if (test__divsf3(0x1.0p+0F, 0x1.0p+0F, UINT32_C(0x3f800000)))
return 1;
// divisor is truncated to exactly 1.0 in UQ1.15
if (test__divsf3(0x1.0p+0F, 0x1.0001p+0F, UINT32_C(0x3f7fff00)))
return 1;

return 0;
Expand Down
104 changes: 100 additions & 4 deletions compiler-rt/test/builtins/Unit/divtf3_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,120 @@ char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
int main()
{
#if __LDBL_MANT_DIG__ == 113
// Returned NaNs are assumed to be qNaN by default

// qNaN / any = qNaN
if (test__divtf3(makeQNaN128(),
0x1.23456789abcdefp+5L,
UINT64_C(0x7fff800000000000),
UINT64_C(0x0)))
return 1;
// NaN / any = NaN
if (test__divtf3(makeNaN128(UINT64_C(0x800030000000)),
if (test__divtf3(makeNaN128(UINT64_C(0x30000000)),
0x1.23456789abcdefp+5L,
UINT64_C(0x7fff800000000000),
UINT64_C(0x0)))
return 1;
// inf / any = inf
if (test__divtf3(makeInf128(),
0x1.23456789abcdefp+5L,
// any / qNaN = qNaN
if (test__divtf3(0x1.23456789abcdefp+5L,
makeQNaN128(),
UINT64_C(0x7fff800000000000),
UINT64_C(0x0)))
return 1;
// any / NaN = NaN
if (test__divtf3(0x1.23456789abcdefp+5L,
makeNaN128(UINT64_C(0x30000000)),
UINT64_C(0x7fff800000000000),
UINT64_C(0x0)))
return 1;

// +Inf / positive = +Inf
if (test__divtf3(makeInf128(), 3.L,
UINT64_C(0x7fff000000000000),
UINT64_C(0x0)))
return 1;
// +Inf / negative = -Inf
if (test__divtf3(makeInf128(), -3.L,
UINT64_C(0xffff000000000000),
UINT64_C(0x0)))
return 1;
// -Inf / positive = -Inf
if (test__divtf3(makeNegativeInf128(), 3.L,
UINT64_C(0xffff000000000000),
UINT64_C(0x0)))
return 1;
// -Inf / negative = +Inf
if (test__divtf3(makeNegativeInf128(), -3.L,
UINT64_C(0x7fff000000000000),
UINT64_C(0x0)))
return 1;

// Inf / Inf = NaN
if (test__divtf3(makeInf128(), makeInf128(),
UINT64_C(0x7fff800000000000),
UINT64_C(0x0)))
return 1;
// 0.0 / 0.0 = NaN
if (test__divtf3(+0x0.0p+0L, +0x0.0p+0L,
UINT64_C(0x7fff800000000000),
UINT64_C(0x0)))
return 1;
// +0.0 / +Inf = +0.0
if (test__divtf3(+0x0.0p+0L, makeInf128(),
UINT64_C(0x0),
UINT64_C(0x0)))
return 1;
// +Inf / +0.0 = +Inf
if (test__divtf3(makeInf128(), +0x0.0p+0L,
UINT64_C(0x7fff000000000000),
UINT64_C(0x0)))
return 1;

// positive / +0.0 = +Inf
if (test__divtf3(+1.0L, +0x0.0p+0L,
UINT64_C(0x7fff000000000000),
UINT64_C(0x0)))
return 1;
// positive / -0.0 = -Inf
if (test__divtf3(+1.0L, -0x0.0p+0L,
UINT64_C(0xffff000000000000),
UINT64_C(0x0)))
return 1;
// negative / +0.0 = -Inf
if (test__divtf3(-1.0L, +0x0.0p+0L,
UINT64_C(0xffff000000000000),
UINT64_C(0x0)))
return 1;
// negative / -0.0 = +Inf
if (test__divtf3(-1.0L, -0x0.0p+0L,
UINT64_C(0x7fff000000000000),
UINT64_C(0x0)))
return 1;

// 1/3
if (test__divtf3(1.L, 3.L,
UINT64_C(0x3ffd555555555555),
UINT64_C(0x5555555555555555)))
return 1;
// smallest normal result
if (test__divtf3(0x1.0p-16381L, 2.L,
UINT64_C(0x0001000000000000),
UINT64_C(0x0)))
return 1;

// divisor is exactly 1.0
if (test__divtf3(0x1.0p+0L,
0x1.0p+0L,
UINT64_C(0x3fff000000000000),
UINT64_C(0x0)))
return 1;
// divisor is truncated to exactly 1.0 in UQ1.63
if (test__divtf3(0x1.0p+0L,
0x1.0000000000000001p+0L,
UINT64_C(0x3ffeffffffffffff),
UINT64_C(0xfffe000000000000)))
return 1;

// any / any
if (test__divtf3(0x1.a23b45362464523375893ab4cdefp+5L,
0x1.eedcbaba3a94546558237654321fp-1L,
Expand Down
15 changes: 15 additions & 0 deletions compiler-rt/test/builtins/Unit/fp_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,29 @@ static inline float makeInf32(void)
return fromRep32(0x7f800000U);
}

static inline float makeNegativeInf32(void)
{
return fromRep32(0xff800000U);
}

static inline double makeInf64(void)
{
return fromRep64(0x7ff0000000000000UL);
}

static inline double makeNegativeInf64(void)
{
return fromRep64(0xfff0000000000000UL);
}

#if __LDBL_MANT_DIG__ == 113
static inline long double makeInf128(void)
{
return fromRep128(0x7fff000000000000UL, 0x0UL);
}

static inline long double makeNegativeInf128(void)
{
return fromRep128(0xffff000000000000UL, 0x0UL);
}
#endif
2 changes: 0 additions & 2 deletions compiler-rt/test/fuzzer/msan.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
FIXME: Fails to find BINGO on s390x.
XFAIL: s390x
REQUIRES: msan
RUN: %msan_compiler %S/SimpleTestStdio.cpp -o %t
RUN: not %run %t -seed=1 -runs=10000000 2>&1 | FileCheck %s --check-prefix=NO-REPORT
Expand Down
21 changes: 7 additions & 14 deletions llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,12 @@ static bool loadStoreBitcastWorkaround(const LLT Ty) {
return false;
if (!Ty.isVector())
return true;
unsigned EltSize = Ty.getElementType().getSizeInBits();

LLT EltTy = Ty.getElementType();
if (EltTy.isPointer())
return true;

unsigned EltSize = EltTy.getSizeInBits();
return EltSize != 32 && EltSize != 64;
}

Expand Down Expand Up @@ -1492,6 +1497,7 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_,
};

auto &Builder = getActionDefinitionsBuilder(Op)
.legalIf(all(isRegisterType(0), isRegisterType(1)))
.lowerFor({{S16, V2S16}})
.lowerIf([=](const LegalityQuery &Query) {
const LLT BigTy = Query.Types[BigTyIdx];
Expand Down Expand Up @@ -1547,19 +1553,6 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_,
}
return std::make_pair(BigTyIdx, LLT::scalar(NewSizeInBits));
})
.legalIf([=](const LegalityQuery &Query) {
const LLT &BigTy = Query.Types[BigTyIdx];
const LLT &LitTy = Query.Types[LitTyIdx];

if (BigTy.isVector() && BigTy.getSizeInBits() < 32)
return false;
if (LitTy.isVector() && LitTy.getSizeInBits() < 32)
return false;

return BigTy.getSizeInBits() % 16 == 0 &&
LitTy.getSizeInBits() % 16 == 0 &&
BigTy.getSizeInBits() <= MaxRegisterSize;
})
// Any vectors left are the wrong size. Scalarize them.
.scalarize(0)
.scalarize(1);
Expand Down
Loading

0 comments on commit 1fe58ed

Please sign in to comment.