-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x86: Properly find the maximum stack slot alignment
Don't assume that stack slots can only be accessed by stack or frame registers. We first find all registers defined by stack or frame registers. Then check memory accesses by such registers, including stack and frame registers. gcc/ PR target/109780 PR target/109093 * config/i386/i386.cc (ix86_update_stack_alignment): New. (ix86_find_all_reg_use_1): Likewise. (ix86_find_all_reg_use): Likewise. (ix86_find_max_used_stack_alignment): Also check memory accesses from registers defined by stack or frame registers. gcc/testsuite/ PR target/109780 PR target/109093 * g++.target/i386/pr109780-1.C: New test. * gcc.target/i386/pr109093-1.c: Likewise. * gcc.target/i386/pr109780-1.c: Likewise. * gcc.target/i386/pr109780-2.c: Likewise. * gcc.target/i386/pr109780-3.c: Likewise. Signed-off-by: H.J. Lu <[email protected]>
- Loading branch information
Showing
6 changed files
with
342 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-require-effective-target c++17 } */ | ||
/* { dg-options "-O2 -mavx2 -mtune=haswell" } */ | ||
|
||
template <typename _Tp> struct remove_reference { | ||
using type = __remove_reference(_Tp); | ||
}; | ||
template <typename T> struct MaybeStorageBase { | ||
T val; | ||
struct Union { | ||
~Union(); | ||
} mStorage; | ||
}; | ||
template <typename T> struct MaybeStorage : MaybeStorageBase<T> { | ||
char mIsSome; | ||
}; | ||
template <typename T, typename U = typename remove_reference<T>::type> | ||
constexpr MaybeStorage<U> Some(T &&); | ||
template <typename T, typename U> constexpr MaybeStorage<U> Some(T &&aValue) { | ||
return {aValue}; | ||
} | ||
template <class> struct Span { | ||
int operator[](long idx) { | ||
int *__trans_tmp_4; | ||
if (__builtin_expect(idx, 0)) | ||
*(int *)__null = false; | ||
__trans_tmp_4 = storage_.data(); | ||
return __trans_tmp_4[idx]; | ||
} | ||
struct { | ||
int *data() { return data_; } | ||
int *data_; | ||
} storage_; | ||
}; | ||
struct Variant { | ||
template <typename RefT> Variant(RefT) {} | ||
}; | ||
long from_i, from___trans_tmp_9; | ||
namespace js::intl { | ||
struct DecimalNumber { | ||
Variant string_; | ||
unsigned long significandStart_; | ||
unsigned long significandEnd_; | ||
bool zero_ = false; | ||
bool negative_; | ||
template <typename CharT> DecimalNumber(CharT string) : string_(string) {} | ||
template <typename CharT> | ||
static MaybeStorage<DecimalNumber> from(Span<const CharT>); | ||
void from(); | ||
}; | ||
} // namespace js::intl | ||
void js::intl::DecimalNumber::from() { | ||
Span<const char16_t> __trans_tmp_3; | ||
from(__trans_tmp_3); | ||
} | ||
template <typename CharT> | ||
MaybeStorage<js::intl::DecimalNumber> | ||
js::intl::DecimalNumber::from(Span<const CharT> chars) { | ||
DecimalNumber number(chars); | ||
if (auto ch = chars[from_i]) { | ||
from_i++; | ||
number.negative_ = ch == '-'; | ||
} | ||
while (from___trans_tmp_9 && chars[from_i]) | ||
; | ||
if (chars[from_i]) | ||
while (chars[from_i - 1]) | ||
number.zero_ = true; | ||
return Some(number); | ||
} | ||
|
||
/* { dg-final { scan-assembler-not "and\[lq\]?\[^\\n\]*-32,\[^\\n\]*sp" } } */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* { dg-do run { target avx2_runtime } } */ | ||
/* { dg-options "-O2 -mavx2 -mtune=znver1 -ftrivial-auto-var-init=zero -fno-stack-protector" } */ | ||
|
||
int a, b, c, d; | ||
char e, f = 1; | ||
short g, h, i; | ||
|
||
__attribute__ ((weak)) | ||
void | ||
run (void) | ||
{ | ||
short j; | ||
|
||
for (; g >= 0; --g) | ||
{ | ||
int *k[10]; | ||
|
||
for (d = 0; d < 10; d++) | ||
k[d] = &b; | ||
|
||
c = *k[1]; | ||
|
||
for (; a;) | ||
j = i - c / f || (e ^= h); | ||
} | ||
} | ||
|
||
int | ||
main (void) | ||
{ | ||
run (); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-O3 -march=skylake" } */ | ||
|
||
char perm[64]; | ||
|
||
void | ||
__attribute__((noipa)) | ||
foo (int n) | ||
{ | ||
for (int i = 0; i < n; ++i) | ||
perm[i] = i; | ||
} | ||
|
||
/* { dg-final { scan-assembler-not "and\[lq\]?\[^\\n\]*-32,\[^\\n\]*sp" } } */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-O3 -march=skylake" } */ | ||
|
||
#define N 9 | ||
|
||
void | ||
f (double x, double y, double *res) | ||
{ | ||
y = -y; | ||
for (int i = 0; i < N; ++i) | ||
{ | ||
double tmp = y; | ||
y = x; | ||
x = tmp; | ||
res[i] = i; | ||
} | ||
res[N] = y * y; | ||
res[N + 1] = x; | ||
} | ||
|
||
/* { dg-final { scan-assembler-not "and\[lq\]?\[^\\n\]*-32,\[^\\n\]*sp" } } */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* { dg-do run { target avx2_runtime } } */ | ||
/* { dg-options "-O2 -mavx2 -mtune=znver1 -fno-stack-protector -fno-stack-clash-protection" } */ | ||
|
||
char a; | ||
static int b, c, f; | ||
char *d = &a; | ||
static char *e = &a; | ||
|
||
__attribute__ ((weak)) | ||
void | ||
g (int h, int i) | ||
{ | ||
int j = 1; | ||
for (; c != -3; c = c - 1) | ||
{ | ||
int k[10]; | ||
f = 0; | ||
for (; f < 10; f++) | ||
k[f] = 0; | ||
*d = k[1]; | ||
if (i < *d) | ||
{ | ||
*e = h; | ||
for (; j < 9; j++) | ||
{ | ||
b = 1; | ||
for (; b < 7; b++) | ||
; | ||
} | ||
} | ||
} | ||
} | ||
|
||
__attribute__ ((weak)) | ||
void | ||
run (void) | ||
{ | ||
g (1, 1); | ||
} | ||
|
||
int | ||
main (void) | ||
{ | ||
run (); | ||
return 0; | ||
} |