Skip to content

Commit f5dff4d

Browse files
authored
Merge branch 'main' into fix-boolean-expr-check
2 parents ae4bc0e + efd9dc8 commit f5dff4d

File tree

10 files changed

+58
-164
lines changed

10 files changed

+58
-164
lines changed

libc/shared/math/expf.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include "shared/libc_common.h"
1313
#include "src/__support/math/expf.h"
14-
#include "src/__support/math/expf_static_rounding.h"
1514

1615
namespace LIBC_NAMESPACE_DECL {
1716
namespace shared {

libc/src/__support/math/expf_static_rounding.h

Lines changed: 0 additions & 43 deletions
This file was deleted.

llvm/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -657,11 +657,6 @@ endif()
657657

658658
set(LLVM_ENABLE_Z3_SOLVER_DEFAULT "${Z3_FOUND}")
659659

660-
include(FindLibcCommonUtils)
661-
if(NOT TARGET llvm-libc-common-utilities)
662-
message(FATAL_ERROR "LLVM libc is not found at ${libc_path}.")
663-
endif()
664-
665660

666661
if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
667662
set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )

llvm/include/llvm/ADT/APFloat.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,8 +1493,6 @@ class APFloat : public APFloatBase {
14931493
friend APFloat frexp(const APFloat &X, int &Exp, roundingMode RM);
14941494
friend IEEEFloat;
14951495
friend DoubleAPFloat;
1496-
1497-
friend APFloat exp(const APFloat &X, roundingMode RM);
14981496
};
14991497

15001498
static_assert(sizeof(APFloat) == sizeof(detail::IEEEFloat),
@@ -1647,10 +1645,6 @@ inline APFloat maximumnum(const APFloat &A, const APFloat &B) {
16471645
return A < B ? B : A;
16481646
}
16491647

1650-
/// Implement IEEE 754-2019 exp functions.
1651-
LLVM_READONLY
1652-
APFloat exp(const APFloat &X, RoundingMode RM = APFloat::rmNearestTiesToEven);
1653-
16541648
inline raw_ostream &operator<<(raw_ostream &OS, const APFloat &V) {
16551649
V.print(OS);
16561650
return OS;

llvm/lib/Support/APFloat.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
#include <cstring>
2929
#include <limits.h>
3030

31-
// Shared headers from LLVM libc
32-
#include "shared/math.h"
33-
3431
#define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL) \
3532
do { \
3633
if (usesLayout<IEEEFloat>(getSemantics())) \
@@ -6158,29 +6155,6 @@ float APFloat::convertToFloat() const {
61586155
return Temp.getIEEE().convertToFloat();
61596156
}
61606157

6161-
static constexpr int getFEnvRoundingMode(llvm::RoundingMode rm) {
6162-
switch (rm) {
6163-
case APFloat::rmTowardPositive:
6164-
return FE_UPWARD;
6165-
case APFloat::rmTowardNegative:
6166-
return FE_DOWNWARD;
6167-
case APFloat::rmTowardZero:
6168-
return FE_TOWARDZERO;
6169-
default:
6170-
// TODO: fix rmNearestTiesToAway for platform without FE_TONEARESTFROMZERO.
6171-
return FE_TONEAREST;
6172-
};
6173-
}
6174-
6175-
APFloat exp(const APFloat &X, RoundingMode rounding_mode) {
6176-
if (&X.getSemantics() == &APFloat::IEEEsingle()) {
6177-
float result = LIBC_NAMESPACE::shared::expf(
6178-
X.convertToFloat(), getFEnvRoundingMode(rounding_mode));
6179-
return APFloat(result);
6180-
}
6181-
llvm_unreachable("Unsupported floating-point semantics");
6182-
}
6183-
61846158
APFloat::Storage::~Storage() {
61856159
if (usesLayout<IEEEFloat>(*semantics)) {
61866160
IEEE.~IEEEFloat();

llvm/lib/Support/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,3 @@ target_include_directories(LLVMSupport
395395
PRIVATE
396396
${LLVM_THIRD_PARTY_DIR}/siphash/include
397397
)
398-
399-
# Integrating LLVM libc's math functions
400-
target_include_directories(LLVMSupport PRIVATE "${LLVM_SOURCE_DIR}/../libc")
401-
if(NOT MSVC)
402-
target_compile_options(LLVMSupport PRIVATE "-Wno-c99-extensions") # _Complex warnings.
403-
endif()

llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ bool AMDGPULibCalls::evaluateScalarMathFunc(const FuncInfo &FInfo, double &Res0,
15311531
return true;
15321532

15331533
case AMDGPULibFunc::EI_EXP:
1534-
Res0 = std::exp(opr0);
1534+
Res0 = exp(opr0);
15351535
return true;
15361536

15371537
case AMDGPULibFunc::EI_EXP2:

llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,9 +665,20 @@ bool SPIRVEmitIntrinsics::walkLogicalAccessChain(
665665
Offset -= STL->getElementOffset(Element);
666666
CurType = ST->getElementType(Element);
667667
OnLiteralIndexing(CurType, Element);
668+
} else if (auto *VT = dyn_cast<FixedVectorType>(CurType)) {
669+
Type *EltTy = VT->getElementType();
670+
TypeSize EltSizeBits = DL.getTypeSizeInBits(EltTy);
671+
assert(EltSizeBits % 8 == 0 &&
672+
"Element type size in bits must be a multiple of 8.");
673+
uint32_t EltTypeSize = EltSizeBits / 8;
674+
assert(Offset < VT->getNumElements() * EltTypeSize);
675+
uint64_t Index = Offset / EltTypeSize;
676+
Offset -= Index * EltTypeSize;
677+
CurType = EltTy;
678+
OnLiteralIndexing(CurType, Index);
679+
668680
} else {
669-
// Vector type indexing should not use GEP.
670-
// So if we have an index left, something is wrong. Giving up.
681+
// Unknown composite kind; give up.
671682
return true;
672683
}
673684
} while (Offset > 0);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
2+
; RUN: llc -verify-machineinstrs -O3 -mtriple=spirv1.6-unknown-vulkan1.3-compute %s -o - | FileCheck %s
3+
; RUN: %if spirv-tools %{ llc -O3 -mtriple=spirv1.6-unknown-vulkan1.3-compute %s -o - -filetype=obj | spirv-val %}
4+
5+
; StructuredBuffer<int4> In : register(t0);
6+
; RWStructuredBuffer<int4> Out : register(u1);
7+
;
8+
; [numthreads(1,1,1)]
9+
; void main() {
10+
; Out[0].y = In[0].y;
11+
; }
12+
13+
@.str = private unnamed_addr constant [3 x i8] c"In\00", align 1
14+
@.str.2 = private unnamed_addr constant [4 x i8] c"Out\00", align 1
15+
16+
define void @main() local_unnamed_addr #0 {
17+
; CHECK-LABEL: main
18+
; CHECK: %33 = OpFunction %2 None %3 ; -- Begin function main
19+
; CHECK-NEXT: %1 = OpLabel
20+
; CHECK-NEXT: %34 = OpVariable %20 Function %29
21+
; CHECK-NEXT: %35 = OpVariable %19 Function %30
22+
; CHECK-NEXT: %36 = OpCopyObject %12 %31
23+
; CHECK-NEXT: %37 = OpCopyObject %10 %32
24+
; CHECK-NEXT: %38 = OpAccessChain %7 %36 %21 %21
25+
; CHECK-NEXT: %39 = OpLoad %6 %38 Aligned 16
26+
; CHECK-NEXT: %40 = OpCompositeExtract %4 %39 1
27+
; CHECK-NEXT: %41 = OpAccessChain %7 %37 %21 %21
28+
; CHECK-NEXT: %42 = OpInBoundsAccessChain %5 %41 %22
29+
; CHECK-NEXT: OpStore %42 %40 Aligned 4
30+
; CHECK-NEXT: OpReturn
31+
; CHECK-NEXT: OpFunctionEnd
32+
entry:
33+
%0 = tail call target("spirv.VulkanBuffer", [0 x <4 x i32>], 12, 0) @llvm.spv.resource.handlefrombinding.tspirv.VulkanBuffer_a0v4i32_12_0t(i32 0, i32 0, i32 1, i32 0, ptr nonnull @.str)
34+
%1 = tail call target("spirv.VulkanBuffer", [0 x <4 x i32>], 12, 1) @llvm.spv.resource.handlefrombinding.tspirv.VulkanBuffer_a0v4i32_12_1t(i32 0, i32 1, i32 1, i32 0, ptr nonnull @.str.2)
35+
%2 = tail call noundef align 16 dereferenceable(16) ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.VulkanBuffer_a0v4i32_12_0t(target("spirv.VulkanBuffer", [0 x <4 x i32>], 12, 0) %0, i32 0)
36+
%3 = load <4 x i32>, ptr addrspace(11) %2, align 16
37+
%4 = extractelement <4 x i32> %3, i64 1
38+
%5 = tail call noundef align 16 dereferenceable(16) ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.VulkanBuffer_a0v4i32_12_1t(target("spirv.VulkanBuffer", [0 x <4 x i32>], 12, 1) %1, i32 0)
39+
%6 = getelementptr inbounds nuw i8, ptr addrspace(11) %5, i64 4
40+
store i32 %4, ptr addrspace(11) %6, align 4
41+
ret void
42+
}
43+
44+
!0 = !{i32 1, !"wchar_size", i32 4}

llvm/unittests/ADT/APFloatTest.cpp

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -10182,78 +10182,4 @@ TEST(APFloatTest, FrexpQuietSNaN) {
1018210182
EXPECT_FALSE(Result.isSignaling());
1018310183
}
1018410184

10185-
TEST(APFloatTest, expf) {
10186-
std::array<llvm::RoundingMode, 4> allRoundingModes = {
10187-
APFloat::rmNearestTiesToEven, APFloat::rmTowardPositive,
10188-
APFloat::rmTowardNegative, APFloat::rmTowardZero};
10189-
for (auto rm : allRoundingModes) {
10190-
// exp(+-0) = 1 for all rounding modes.
10191-
EXPECT_EQ(1.0f, llvm::exp(APFloat(0.0f), rm).convertToFloat());
10192-
EXPECT_EQ(1.0f, llvm::exp(APFloat(-0.0f), rm).convertToFloat());
10193-
// exp(+Inf) = +Inf for all rounding modes.
10194-
EXPECT_EQ(std::numeric_limits<float>::infinity(),
10195-
llvm::exp(APFloat::getInf(APFloat::IEEEsingle(), false), rm)
10196-
.convertToFloat());
10197-
// exp(-Inf) = 0 for all rounding modes.
10198-
EXPECT_EQ(0.0f, llvm::exp(APFloat::getInf(APFloat::IEEEsingle(), true), rm)
10199-
.convertToFloat());
10200-
// exp(NaN) = NaN for all rounding modes.
10201-
EXPECT_TRUE(llvm::exp(APFloat::getNaN(APFloat::IEEEsingle()), rm).isNaN());
10202-
}
10203-
// exp(1)
10204-
EXPECT_EQ(
10205-
0x1.5bf0a8p1f,
10206-
llvm::exp(APFloat(1.0f), APFloat::rmNearestTiesToEven).convertToFloat());
10207-
EXPECT_EQ(
10208-
0x1.5bf0aap1f,
10209-
llvm::exp(APFloat(1.0f), APFloat::rmTowardPositive).convertToFloat());
10210-
EXPECT_EQ(
10211-
0x1.5bf0a8p1f,
10212-
llvm::exp(APFloat(1.0f), APFloat::rmTowardNegative).convertToFloat());
10213-
EXPECT_EQ(0x1.5bf0a8p1f,
10214-
llvm::exp(APFloat(1.0f), APFloat::rmTowardZero).convertToFloat());
10215-
// exp(float max)
10216-
EXPECT_EQ(std::numeric_limits<float>::infinity(),
10217-
llvm::exp(APFloat::getLargest(APFloat::IEEEsingle(), false),
10218-
APFloat::rmNearestTiesToEven)
10219-
.convertToFloat());
10220-
EXPECT_EQ(std::numeric_limits<float>::infinity(),
10221-
llvm::exp(APFloat::getLargest(APFloat::IEEEsingle(), false),
10222-
APFloat::rmTowardPositive)
10223-
.convertToFloat());
10224-
EXPECT_EQ(std::numeric_limits<float>::max(),
10225-
llvm::exp(APFloat::getLargest(APFloat::IEEEsingle(), false),
10226-
APFloat::rmTowardNegative)
10227-
.convertToFloat());
10228-
EXPECT_EQ(std::numeric_limits<float>::max(),
10229-
llvm::exp(APFloat::getLargest(APFloat::IEEEsingle(), false),
10230-
APFloat::rmTowardZero)
10231-
.convertToFloat());
10232-
// exp(min_denormal)
10233-
EXPECT_EQ(1.0f, llvm::exp(APFloat::getSmallest(APFloat::IEEEsingle(), false),
10234-
APFloat::rmNearestTiesToEven)
10235-
.convertToFloat());
10236-
EXPECT_EQ(0x1.000002p0f,
10237-
llvm::exp(APFloat::getSmallest(APFloat::IEEEsingle(), false),
10238-
APFloat::rmTowardPositive)
10239-
.convertToFloat());
10240-
EXPECT_EQ(1.0f, llvm::exp(APFloat::getSmallest(APFloat::IEEEsingle(), false),
10241-
APFloat::rmTowardNegative)
10242-
.convertToFloat());
10243-
EXPECT_EQ(1.0f, llvm::exp(APFloat::getSmallest(APFloat::IEEEsingle(), false),
10244-
APFloat::rmTowardZero)
10245-
.convertToFloat());
10246-
// Default rounding mode.
10247-
// exp(-1)
10248-
EXPECT_EQ(0x1.78b564p-2f, llvm::exp(APFloat(-1.0f)).convertToFloat());
10249-
EXPECT_EQ(
10250-
0x1.78b564p-2f,
10251-
llvm::exp(APFloat(-1.0f), APFloat::rmTowardPositive).convertToFloat());
10252-
EXPECT_EQ(
10253-
0x1.78b562p-2f,
10254-
llvm::exp(APFloat(-1.0f), APFloat::rmTowardNegative).convertToFloat());
10255-
EXPECT_EQ(0x1.78b562p-2f,
10256-
llvm::exp(APFloat(-1.0f), APFloat::rmTowardZero).convertToFloat());
10257-
}
10258-
1025910185
} // namespace

0 commit comments

Comments
 (0)