Skip to content

Commit 387d39f

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:0897373f1a32 into amd-gfx:548f6aed503a
Local branch amd-gfx 548f6ae Merged main:08f77241c0d9 into amd-gfx:182209fab483 Remote branch main 0897373 [Clang][test] Relax checking for libclang_rt.asan.so and libclang_rt.asan_static.a on arm android. (llvm#121361)
2 parents 548f6ae + 0897373 commit 387d39f

File tree

14 files changed

+785
-1452
lines changed

14 files changed

+785
-1452
lines changed

clang/test/Driver/sanitizer-ld.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@
332332
// RUN: | %{filecheck} --check-prefix=CHECK-ASAN-ANDROID-SHARED-LIBASAN
333333
//
334334
// CHECK-ASAN-ANDROID-SHARED-LIBASAN-NOT: argument unused during compilation: '-shared-libsan'
335-
// CHECK-ASAN-ANDROID-SHARED-LIBASAN: libclang_rt.asan.so"
336-
// CHECK-ASAN-ANDROID-SHARED-LIBASAN: libclang_rt.asan_static.a"
335+
// CHECK-ASAN-ANDROID-SHARED-LIBASAN: libclang_rt.asan{{.*}}.so"
336+
// CHECK-ASAN-ANDROID-SHARED-LIBASAN: libclang_rt.asan_static{{.*}}.a"
337337
//
338338
// RUN: %clang -### %s 2>&1 \
339339
// RUN: --target=arm-linux-androideabi -fuse-ld=ld -fsanitize=address \

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ set(x86_80_BIT_SOURCES
310310
mulxc3.c
311311
powixf2.c
312312
trunctfxf2.c
313+
truncxfhf2.c
313314
)
314315

315316
if (NOT MSVC)

compiler-rt/lib/builtins/truncxfhf2.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//===-- lib/truncsfhf2.c - long double -> half conversion ---------*- C -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#define SRC_SINGLE
10+
#define DST_HALF
11+
#include "fp_trunc_impl.inc"
12+
13+
COMPILER_RT_ABI dst_t __truncxfhf2(xf_float a) {
14+
return __truncXfYf2__((float)a);
15+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// RUN: %clang_builtins %s %librt -o %t && %run %t
2+
// REQUIRES: librt_has_truncxfhf2
3+
4+
#include <stdio.h>
5+
6+
#include "fp_test.h"
7+
8+
#if HAS_80_BIT_LONG_DOUBLE
9+
10+
TYPE_FP16 __truncxfhf2(xf_float f);
11+
12+
int test_truncxfhf2(uint16_t inputHi, uint64_t inputLo, uint16_t e) {
13+
xf_float a = F80FromRep80(inputHi, inputLo);
14+
TYPE_FP16 x = __truncxfhf2(a);
15+
int ret = compareResultH(x, e);
16+
if (ret) {
17+
printf("error in test__truncxfhf2(%Lf) = %#.4x, "
18+
"expected %#.4x\n",
19+
a, toRep16(x), e);
20+
}
21+
return ret;
22+
}
23+
24+
int main() {
25+
// Small positive value
26+
if (test_truncxfhf2(UINT16_C(0x3ffb), UINT64_C(0xccc0000000000000),
27+
UINT16_C(0x2e66)))
28+
return 1;
29+
30+
// Small negative value
31+
if (test_truncxfhf2(UINT16_C(0xbffb), UINT64_C(0xccc0000000000000),
32+
UINT16_C(0xae66)))
33+
return 1;
34+
35+
// Zero
36+
if (test_truncxfhf2(UINT16_C(0x0), UINT64_C(0x0), UINT16_C(0)))
37+
return 1;
38+
39+
// Smallest positive non-zero value
40+
if (test_truncxfhf2(UINT16_C(0x3fef), UINT64_C(0x8000000000000000),
41+
UINT16_C(0x0100)))
42+
return 1;
43+
44+
// Smallest negative non-zero value
45+
if (test_truncxfhf2(UINT16_C(0xbfef), UINT64_C(0x8000000000000000),
46+
UINT16_C(0x8100)))
47+
return 1;
48+
49+
// Positive infinity
50+
if (test_truncxfhf2(UINT16_C(0x7fff), UINT64_C(0x8000000000000000),
51+
UINT16_C(0x7c00U)))
52+
return 1;
53+
54+
// Negative infinity
55+
if (test_truncxfhf2(UINT16_C(0xffff), UINT64_C(0x8000000000000000),
56+
UINT16_C(0xfc00U)))
57+
return 1;
58+
59+
// NaN
60+
if (test_truncxfhf2(UINT16_C(0x7fff), UINT64_C(0xc000000000000000),
61+
UINT16_C(0x7e00U)))
62+
return 1;
63+
64+
return 0;
65+
}
66+
67+
#else
68+
69+
int main() {
70+
printf("skipped\n");
71+
return 0;
72+
}
73+
74+
#endif

libc/test/UnitTest/FPMatcher.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ template <typename T, TestCond Condition> class CFPMatcher : public Matcher<T> {
131131
else if constexpr (cpp::is_complex_type_same<T, _Complex long double>())
132132
return matchComplex<long double>();
133133
#ifdef LIBC_TYPES_HAS_CFLOAT16
134-
else if constexpr (cpp::is_complex_type_same<T, cfloat16>)
134+
else if constexpr (cpp::is_complex_type_same<T, cfloat16>())
135135
return matchComplex<float16>();
136136
#endif
137137
#ifdef LIBC_TYPES_HAS_CFLOAT128
138-
else if constexpr (cpp::is_complex_type_same<T, cfloat128>)
138+
else if constexpr (cpp::is_complex_type_same<T, cfloat128>())
139139
return matchComplex<float128>();
140140
#endif
141141
}
@@ -148,11 +148,11 @@ template <typename T, TestCond Condition> class CFPMatcher : public Matcher<T> {
148148
else if constexpr (cpp::is_complex_type_same<T, _Complex long double>())
149149
return explainErrorComplex<long double>();
150150
#ifdef LIBC_TYPES_HAS_CFLOAT16
151-
else if constexpr (cpp::is_complex_type_same<T, cfloat16>)
151+
else if constexpr (cpp::is_complex_type_same<T, cfloat16>())
152152
return explainErrorComplex<float16>();
153153
#endif
154154
#ifdef LIBC_TYPES_HAS_CFLOAT128
155-
else if constexpr (cpp::is_complex_type_same<T, cfloat128>)
155+
else if constexpr (cpp::is_complex_type_same<T, cfloat128>())
156156
return explainErrorComplex<float128>();
157157
#endif
158158
}

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 522523
19+
#define LLVM_MAIN_REVISION 522528
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3489,10 +3489,10 @@ bool LoopVectorizationCostModel::interleavedAccessCanBeWidened(
34893489
if (hasIrregularType(ScalarTy, DL))
34903490
return false;
34913491

3492-
// For scalable vectors, the only interleave factor currently supported
3493-
// must be power of 2 since we require the (de)interleave2 intrinsics
3494-
// instead of shufflevectors.
3495-
if (VF.isScalable() && !isPowerOf2_32(InterleaveFactor))
3492+
// We currently only know how to emit interleave/deinterleave with
3493+
// Factor=2 for scalable vectors. This is purely an implementation
3494+
// limit.
3495+
if (VF.isScalable() && InterleaveFactor != 2)
34963496
return false;
34973497

34983498
// If the group involves a non-integral pointer, we may not be able to
@@ -9193,9 +9193,9 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
91939193
CM.getWideningDecision(IG->getInsertPos(), VF) ==
91949194
LoopVectorizationCostModel::CM_Interleave);
91959195
// For scalable vectors, the only interleave factor currently supported
9196-
// must be power of 2 since we require the (de)interleave2 intrinsics
9197-
// instead of shufflevectors.
9198-
assert((!Result || !VF.isScalable() || isPowerOf2_32(IG->getFactor())) &&
9196+
// is 2 since we require the (de)interleave2 intrinsics instead of
9197+
// shufflevectors.
9198+
assert((!Result || !VF.isScalable() || IG->getFactor() == 2) &&
91999199
"Unsupported interleave factor for scalable vectors");
92009200
return Result;
92019201
};

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 23 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2789,21 +2789,10 @@ static Value *interleaveVectors(IRBuilderBase &Builder, ArrayRef<Value *> Vals,
27892789
// Scalable vectors cannot use arbitrary shufflevectors (only splats), so
27902790
// must use intrinsics to interleave.
27912791
if (VecTy->isScalableTy()) {
2792-
assert(isPowerOf2_32(Factor) && "Unsupported interleave factor for "
2793-
"scalable vectors, must be power of 2");
2794-
SmallVector<Value *> InterleavingValues(Vals);
2795-
// When interleaving, the number of values will be shrunk until we have the
2796-
// single final interleaved value.
2797-
auto *InterleaveTy = cast<VectorType>(InterleavingValues[0]->getType());
2798-
for (unsigned Midpoint = Factor / 2; Midpoint > 0; Midpoint /= 2) {
2799-
InterleaveTy = VectorType::getDoubleElementsVectorType(InterleaveTy);
2800-
for (unsigned I = 0; I < Midpoint; ++I)
2801-
InterleavingValues[I] = Builder.CreateIntrinsic(
2802-
InterleaveTy, Intrinsic::vector_interleave2,
2803-
{InterleavingValues[I], InterleavingValues[Midpoint + I]},
2804-
/*FMFSource=*/nullptr, Name);
2805-
}
2806-
return InterleavingValues[0];
2792+
VectorType *WideVecTy = VectorType::getDoubleElementsVectorType(VecTy);
2793+
return Builder.CreateIntrinsic(WideVecTy, Intrinsic::vector_interleave2,
2794+
Vals,
2795+
/*FMFSource=*/nullptr, Name);
28072796
}
28082797

28092798
// Fixed length. Start by concatenating all vectors into a wide vector.
@@ -2889,11 +2878,15 @@ void VPInterleaveRecipe::execute(VPTransformState &State) {
28892878
&InterleaveFactor](Value *MaskForGaps) -> Value * {
28902879
if (State.VF.isScalable()) {
28912880
assert(!MaskForGaps && "Interleaved groups with gaps are not supported.");
2892-
assert(isPowerOf2_32(InterleaveFactor) &&
2881+
assert(InterleaveFactor == 2 &&
28932882
"Unsupported deinterleave factor for scalable vectors");
28942883
auto *ResBlockInMask = State.get(BlockInMask);
2895-
SmallVector<Value *> Ops(InterleaveFactor, ResBlockInMask);
2896-
return interleaveVectors(State.Builder, Ops, "interleaved.mask");
2884+
SmallVector<Value *, 2> Ops = {ResBlockInMask, ResBlockInMask};
2885+
auto *MaskTy = VectorType::get(State.Builder.getInt1Ty(),
2886+
State.VF.getKnownMinValue() * 2, true);
2887+
return State.Builder.CreateIntrinsic(
2888+
MaskTy, Intrinsic::vector_interleave2, Ops,
2889+
/*FMFSource=*/nullptr, "interleaved.mask");
28972890
}
28982891

28992892
if (!BlockInMask)
@@ -2933,48 +2926,22 @@ void VPInterleaveRecipe::execute(VPTransformState &State) {
29332926
ArrayRef<VPValue *> VPDefs = definedValues();
29342927
const DataLayout &DL = State.CFG.PrevBB->getDataLayout();
29352928
if (VecTy->isScalableTy()) {
2936-
assert(isPowerOf2_32(InterleaveFactor) &&
2929+
assert(InterleaveFactor == 2 &&
29372930
"Unsupported deinterleave factor for scalable vectors");
29382931

2939-
// Scalable vectors cannot use arbitrary shufflevectors (only splats),
2940-
// so must use intrinsics to deinterleave.
2941-
SmallVector<Value *> DeinterleavedValues(InterleaveFactor);
2942-
DeinterleavedValues[0] = NewLoad;
2943-
// For the case of InterleaveFactor > 2, we will have to do recursive
2944-
// deinterleaving, because the current available deinterleave intrinsic
2945-
// supports only Factor of 2, otherwise it will bailout after first
2946-
// iteration.
2947-
// When deinterleaving, the number of values will double until we
2948-
// have "InterleaveFactor".
2949-
for (unsigned NumVectors = 1; NumVectors < InterleaveFactor;
2950-
NumVectors *= 2) {
2951-
// Deinterleave the elements within the vector
2952-
SmallVector<Value *> TempDeinterleavedValues(NumVectors);
2953-
for (unsigned I = 0; I < NumVectors; ++I) {
2954-
auto *DiTy = DeinterleavedValues[I]->getType();
2955-
TempDeinterleavedValues[I] = State.Builder.CreateIntrinsic(
2956-
Intrinsic::vector_deinterleave2, DiTy, DeinterleavedValues[I],
2957-
/*FMFSource=*/nullptr, "strided.vec");
2958-
}
2959-
// Extract the deinterleaved values:
2960-
for (unsigned I = 0; I < 2; ++I)
2961-
for (unsigned J = 0; J < NumVectors; ++J)
2962-
DeinterleavedValues[NumVectors * I + J] =
2963-
State.Builder.CreateExtractValue(TempDeinterleavedValues[J], I);
2964-
}
2965-
2966-
#ifndef NDEBUG
2967-
for (Value *Val : DeinterleavedValues)
2968-
assert(Val && "NULL Deinterleaved Value");
2969-
#endif
2970-
for (unsigned I = 0, J = 0; I < InterleaveFactor; ++I) {
2932+
// Scalable vectors cannot use arbitrary shufflevectors (only splats),
2933+
// so must use intrinsics to deinterleave.
2934+
Value *DI = State.Builder.CreateIntrinsic(
2935+
Intrinsic::vector_deinterleave2, VecTy, NewLoad,
2936+
/*FMFSource=*/nullptr, "strided.vec");
2937+
unsigned J = 0;
2938+
for (unsigned I = 0; I < InterleaveFactor; ++I) {
29712939
Instruction *Member = Group->getMember(I);
2972-
Value *StridedVec = DeinterleavedValues[I];
2973-
if (!Member) {
2974-
// This value is not needed as it's not used
2975-
static_cast<Instruction *>(StridedVec)->eraseFromParent();
2940+
2941+
if (!Member)
29762942
continue;
2977-
}
2943+
2944+
Value *StridedVec = State.Builder.CreateExtractValue(DI, I);
29782945
// If this member has different type, cast the result type.
29792946
if (Member->getType() != ScalarTy) {
29802947
VectorType *OtherVTy = VectorType::get(Member->getType(), State.VF);

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,10 @@ class VectorCombine {
139139

140140
void eraseInstruction(Instruction &I) {
141141
LLVM_DEBUG(dbgs() << "VC: Erasing: " << I << '\n');
142-
SmallVector<Value *> Ops(I.operands());
142+
for (Value *Op : I.operands())
143+
Worklist.pushValue(Op);
143144
Worklist.remove(&I);
144145
I.eraseFromParent();
145-
146-
// Push remaining users and then the operand itself - allows further folds
147-
// that were hindered by OneUse limits.
148-
for (Value *Op : Ops)
149-
if (auto *OpI = dyn_cast<Instruction>(Op)) {
150-
Worklist.pushUsersToWorkList(*OpI);
151-
Worklist.pushValue(OpI);
152-
}
153146
}
154147
};
155148
} // namespace

0 commit comments

Comments
 (0)