Skip to content

Commit

Permalink
Merge pull request nervosnetwork#2 from libraries/cherry-pick-ff14585…
Browse files Browse the repository at this point in the history
…eb02f

Cherry-pick llvm/llvm-project@ff14585eb02f
  • Loading branch information
XuJiandong authored Oct 26, 2023
2 parents 8005bb7 + 0739f11 commit 5dc696f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ This project is **completely** from the llvm project:
- Branch: `release/16.x`
- Commit: `7cbf1a259`

At the same time, we pulled the following commit from LLVM main branch to fix some bugs in clang-16:

- <https://github.com/llvm/llvm-project/commit/ff14585eb02f>

See more: https://github.com/llvm/llvm-project/blob/release/16.x/compiler-rt/lib/builtins/README.txt
7 changes: 4 additions & 3 deletions compiler-rt/lib/builtins/floatsidf.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@ COMPILER_RT_ABI fp_t __floatsidf(si_int a) {

// All other cases begin by extracting the sign and absolute value of a
rep_t sign = 0;
su_int aAbs = (su_int)a;
if (a < 0) {
sign = signBit;
a = -a;
aAbs = -aAbs;
}

// Exponent of (fp_t)a is the width of abs(a).
const int exponent = (aWidth - 1) - clzsi(a);
const int exponent = (aWidth - 1) - clzsi(aAbs);
rep_t result;

// Shift a into the significand field and clear the implicit bit. Extra
// cast to unsigned int is necessary to get the correct behavior for
// the input INT_MIN.
const int shift = significandBits - exponent;
result = (rep_t)(su_int)a << shift ^ implicitBit;
result = (rep_t)aAbs << shift ^ implicitBit;

// Insert the exponent
result += (rep_t)(exponent + exponentBias) << significandBits;
Expand Down
11 changes: 6 additions & 5 deletions compiler-rt/lib/builtins/floatsisf.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,24 @@ COMPILER_RT_ABI fp_t __floatsisf(si_int a) {

// All other cases begin by extracting the sign and absolute value of a
rep_t sign = 0;
su_int aAbs = (su_int)a;
if (a < 0) {
sign = signBit;
a = -a;
aAbs = -aAbs;
}

// Exponent of (fp_t)a is the width of abs(a).
const int exponent = (aWidth - 1) - clzsi(a);
const int exponent = (aWidth - 1) - clzsi(aAbs);
rep_t result;

// Shift a into the significand field, rounding if it is a right-shift
if (exponent <= significandBits) {
const int shift = significandBits - exponent;
result = (rep_t)a << shift ^ implicitBit;
result = (rep_t)aAbs << shift ^ implicitBit;
} else {
const int shift = exponent - significandBits;
result = (rep_t)a >> shift ^ implicitBit;
rep_t round = (rep_t)a << (typeWidth - shift);
result = (rep_t)aAbs >> shift ^ implicitBit;
rep_t round = (rep_t)aAbs << (typeWidth - shift);
if (round > signBit)
result++;
if (round == signBit)
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/builtins/floatsitf.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ COMPILER_RT_ABI fp_t __floatsitf(si_int a) {
su_int aAbs = (su_int)a;
if (a < 0) {
sign = signBit;
aAbs = ~(su_int)a + (su_int)1U;
aAbs = -aAbs;
}

// Exponent of (fp_t)a is the width of abs(a).
Expand Down

0 comments on commit 5dc696f

Please sign in to comment.