[Bug middle-end/107107] Wrong codegen from TBAA when stores to distinct same-mode types are collapsed?

2022-09-30 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107107

Andrew Pinski  changed:

   What|Removed |Added

  Known to fail||4.1.2, 4.4.7, 4.5.3

--- Comment #3 from Andrew Pinski  ---
Here is a testcase which has failed since before 4.1.2:
```
static inline void set_longish(int is_long_long, void *p, long x)
{
if (is_long_long)
*(long long*)p = x;
else
*(long*)p = x;
}
static long test(long long *p, int index, int mode)
{
*p = 1;
set_longish(mode, p+index, 2);
return *p;
}
long (*volatile vtest)(long long*, int, int) = test;
#include 
int main(void)
{
long long x;
long result = vtest(, 0, 1);
printf("%lu/%llu\n", result, x);
}
```
The only difference from the original testcase is marking set_longish as static
inline. I suspect what changed between 4.7 and 4.8 for the original testcase is
inlining.

[Bug middle-end/107107] Wrong codegen from TBAA when stores to distinct same-mode types are collapsed?

2022-09-30 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107107

--- Comment #2 from Andrew Pinski  ---
Confirmed. I don't think it is exactly TBAA which is causing the issue but
rather the way PRE does aliasing walks.

Take:
```
static inline void set_longish(int is_long, void *p, long x)
{
if (is_long)
*(long*)p = x;
else
*(long long*)p = x;
}
static long test(long long *p, int index, int mode)
{
*p = 1;
set_longish(mode, p+index, 2);
return *p;
}
long (*volatile vtest)(long long*, int, int) = test;
#include 
int main(void)
{
long long x;
long result = vtest(, 0, 0);
printf("%lu/%llu\n", result, x);
}
```
Which is only difference by which order the if statement (and mode which is
swapped). This case works.

[Bug middle-end/107107] Wrong codegen from TBAA when stores to distinct same-mode types are collapsed?

2022-09-30 Thread bugdal at aerifal dot cx via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107107

--- Comment #1 from Rich Felker  ---
There's also a potentially related test case at https://godbolt.org/z/jfv1Ge6v4
- I'm not yet clear on whether it's likely to have the same root cause.