* [Bug c/106755] Incorrect code gen for altivec intrinsics with constant inputs
2022-08-26 14:30 [Bug c/106755] New: Incorrect code gen for altivec intrinsics with constant inputs munroesj at gcc dot gnu.org
@ 2022-08-26 15:18 ` bergner at gcc dot gnu.org
2022-08-26 16:35 ` bergner at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: bergner at gcc dot gnu.org @ 2022-08-26 15:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106755
Peter Bergner <bergner at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-08-26
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
CC| |bergner at gcc dot gnu.org,
| |linkw at gcc dot gnu.org,
| |meissner at gcc dot gnu.org,
| |segher at gcc dot gnu.org
--- Comment #1 from Peter Bergner <bergner at gcc dot gnu.org> ---
I can confirm I see the pveclib test errors. I'm having a look.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/106755] Incorrect code gen for altivec intrinsics with constant inputs
2022-08-26 14:30 [Bug c/106755] New: Incorrect code gen for altivec intrinsics with constant inputs munroesj at gcc dot gnu.org
2022-08-26 15:18 ` [Bug c/106755] " bergner at gcc dot gnu.org
@ 2022-08-26 16:35 ` bergner at gcc dot gnu.org
2022-08-26 17:31 ` [Bug target/106755] " pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: bergner at gcc dot gnu.org @ 2022-08-26 16:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106755
--- Comment #2 from Peter Bergner <bergner at gcc dot gnu.org> ---
So the tests (I've removed all static inline usage and always use -fno-inline)
pass with -O1 and fail with -O2 and -O3. Looking at all of the optimizations
enabled by -O2 that are not in -O1 and using -fno-* for them, the only option
that allows the tests to pass with -O2 is -fno-strict-aliasing. That said,
-Wall and -Wstrict-aliasing do not flag any warnings with the code. I suppose
they could miss some issues in the test case code???
In addition, if I move the vec_muludq() function to its own source file, then
the tests pass with -O2 and -O3.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/106755] Incorrect code gen for altivec intrinsics with constant inputs
2022-08-26 14:30 [Bug c/106755] New: Incorrect code gen for altivec intrinsics with constant inputs munroesj at gcc dot gnu.org
2022-08-26 15:18 ` [Bug c/106755] " bergner at gcc dot gnu.org
2022-08-26 16:35 ` bergner at gcc dot gnu.org
@ 2022-08-26 17:31 ` pinskia at gcc dot gnu.org
2022-08-26 18:38 ` bergner at gcc dot gnu.org
2022-08-26 21:01 ` segher at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-26 17:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106755
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|NEW |RESOLVED
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Peter Bergner from comment #2)
> That said, -Wall and -Wstrict-aliasing do not flag
> any warnings with the code. I suppose they could miss some issues in the
> test case code???
typedef __vector unsigned int vui32_t;
...
typedef __vector unsigned __int128 vui128_t;
...
static inline vui128_t
vec_muludq (vui128_t *mulu, vui128_t a, vui128_t b)
{
...
*mulu = (vui128_t) t;
...
int
test_muludq (void)
{
vui32_t i, j, k, l /*, m*/;
....
k = (vui32_t) test_vec_muludq((vui128_t* )&l, (vui128_t)i, (vui128_t)j);
....
print_vint128_prod ("2**96-1 * 2**96-1 ", k, i, j, l);
So yes there is aliasing violation as you do the store as vui128_t aka
"__vector unsigned __int128" (which has the same aliasing set) as "__int128"
but then do the load from it as vui32_t aka "__vector unsigned int vui32_t"
(which is the same aliasing set as int).
-Wstrict-aliasing=3 might warn about this case I can't remember exactly of the
levels of the options but the -Wstrict-aliasing warnings are always not going
to happen, sometimes it is easier to read the code.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/106755] Incorrect code gen for altivec intrinsics with constant inputs
2022-08-26 14:30 [Bug c/106755] New: Incorrect code gen for altivec intrinsics with constant inputs munroesj at gcc dot gnu.org
` (2 preceding siblings ...)
2022-08-26 17:31 ` [Bug target/106755] " pinskia at gcc dot gnu.org
@ 2022-08-26 18:38 ` bergner at gcc dot gnu.org
2022-08-26 21:01 ` segher at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: bergner at gcc dot gnu.org @ 2022-08-26 18:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106755
--- Comment #4 from Peter Bergner <bergner at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> So yes there is aliasing violation as you do the store as vui128_t aka
> "__vector unsigned __int128" (which has the same aliasing set) as "__int128"
> but then do the load from it as vui32_t aka "__vector unsigned int vui32_t"
> (which is the same aliasing set as int).
Yes, I came to the same conclusion and sent Steve a patch offline that fixes
the issue.
> -Wstrict-aliasing=3 might warn about this case I can't remember exactly of
> the levels of the options but the -Wstrict-aliasing warnings are always not
> going to happen, sometimes it is easier to read the code.
Ah, I didn't realize we could increase the warning level. Cool! It seems
-Wstrict-aliasing=2 is enough to catch the problem:
gcc -O3 -Wall -c -fmessage-length=0 -mcpu=power8 -mtune=power8
-Wstrict-aliasing=2 -m64 ../src/vec_bug6.c
../src/vec_bug6.c: In function ‘test_muludq’:
../src/vec_bug6.c:969:45: warning: dereferencing type-punned pointer will break
strict-aliasing rules [-Wstrict-aliasing]
969 | k = (vui32_t) test_vec_muludq((vui128_t* )&l, (vui128_t)i,
(vui128_t)j);
...
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/106755] Incorrect code gen for altivec intrinsics with constant inputs
2022-08-26 14:30 [Bug c/106755] New: Incorrect code gen for altivec intrinsics with constant inputs munroesj at gcc dot gnu.org
` (3 preceding siblings ...)
2022-08-26 18:38 ` bergner at gcc dot gnu.org
@ 2022-08-26 21:01 ` segher at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: segher at gcc dot gnu.org @ 2022-08-26 21:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106755
--- Comment #5 from Segher Boessenkool <segher at gcc dot gnu.org> ---
(In reply to Peter Bergner from comment #2)
> So the tests (I've removed all static inline usage and always use
> -fno-inline) pass with -O1 and fail with -O2 and -O3. Looking at all of the
> optimizations enabled by -O2 that are not in -O1 and using -fno-* for them,
> the only option that allows the tests to pass with -O2 is
> -fno-strict-aliasing. That said, -Wall and -Wstrict-aliasing do not flag
> any warnings with the code. I suppose they could miss some issues in the
> test case code???
There are 10 cases (in just the .cc files) that use "optimize > 1", and
another 5 that do "optimize >= 2".
The -O options do more than just being shorthand for some -f option selections.
^ permalink raw reply [flat|nested] 6+ messages in thread