* [Bug tree-optimization/105431] ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow()
2022-04-29 5:27 [Bug tree-optimization/105431] New: ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow() zsojka at seznam dot cz
@ 2022-04-29 6:45 ` rguenth at gcc dot gnu.org
2022-04-29 6:45 ` rguenth at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-29 6:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I can't reproduce in my dev tree but I guess the following will fix it?
diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
index 7555793948e..f3efd1ef4b2 100644
--- a/gcc/tree-ssa-math-opts.cc
+++ b/gcc/tree-ssa-math-opts.cc
@@ -1495,7 +1495,7 @@ powi_cost (HOST_WIDE_INT n)
static tree
powi_as_mults_1 (gimple_stmt_iterator *gsi, location_t loc, tree type,
- HOST_WIDE_INT n, tree *cache)
+ unsigned HOST_WIDE_INT n, tree *cache)
{
tree op0, op1, ssa_target;
unsigned HOST_WIDE_INT digit;
@@ -1548,7 +1548,7 @@ powi_as_mults (gimple_stmt_iterator *gsi, location_t loc,
memset (cache, 0, sizeof (cache));
cache[1] = arg0;
- result = powi_as_mults_1 (gsi, loc, type, (n < 0) ? -n : n, cache);
+ result = powi_as_mults_1 (gsi, loc, type, absu_hwi (n), cache);
if (n >= 0)
return result;
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105431] ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow()
2022-04-29 5:27 [Bug tree-optimization/105431] New: ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow() zsojka at seznam dot cz
2022-04-29 6:45 ` [Bug tree-optimization/105431] " rguenth at gcc dot gnu.org
@ 2022-04-29 6:45 ` rguenth at gcc dot gnu.org
2022-04-29 8:04 ` jakub at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-29 6:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-04-29
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
Ever confirmed|0 |1
Status|UNCONFIRMED |ASSIGNED
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105431] ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow()
2022-04-29 5:27 [Bug tree-optimization/105431] New: ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow() zsojka at seznam dot cz
2022-04-29 6:45 ` [Bug tree-optimization/105431] " rguenth at gcc dot gnu.org
2022-04-29 6:45 ` rguenth at gcc dot gnu.org
@ 2022-04-29 8:04 ` jakub at gcc dot gnu.org
2022-04-29 8:17 ` rguenther at suse dot de
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-04-29 8:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
While you touch it, shouldn't e.g.
/* Avoid largest negative number. */
if (n != -n
be fixed as well (don't we fold that as n != 0?)?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105431] ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow()
2022-04-29 5:27 [Bug tree-optimization/105431] New: ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow() zsojka at seznam dot cz
` (2 preceding siblings ...)
2022-04-29 8:04 ` jakub at gcc dot gnu.org
@ 2022-04-29 8:17 ` rguenther at suse dot de
2022-04-29 8:23 ` zsojka at seznam dot cz
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenther at suse dot de @ 2022-04-29 8:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431
--- Comment #3 from rguenther at suse dot de <rguenther at suse dot de> ---
On Fri, 29 Apr 2022, jakub at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431
>
> Jakub Jelinek <jakub at gcc dot gnu.org> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> CC| |jakub at gcc dot gnu.org
>
> --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> While you touch it, shouldn't e.g.
> /* Avoid largest negative number. */
> if (n != -n
> be fixed as well (don't we fold that as n != 0?)?
Yeah, that probably guarded against the other misuses of -n ... in
fact we should handle the most negative number fine now so I'm
going to just remove this check (n == 0 is also handled well).
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105431] ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow()
2022-04-29 5:27 [Bug tree-optimization/105431] New: ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow() zsojka at seznam dot cz
` (3 preceding siblings ...)
2022-04-29 8:17 ` rguenther at suse dot de
@ 2022-04-29 8:23 ` zsojka at seznam dot cz
2022-04-29 9:10 ` cvs-commit at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: zsojka at seznam dot cz @ 2022-04-29 8:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431
--- Comment #4 from Zdenek Sojka <zsojka at seznam dot cz> ---
(In reply to Richard Biener from comment #1)
> I can't reproduce in my dev tree but I guess the following will fix it?
>
> diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
> index 7555793948e..f3efd1ef4b2 100644
> --- a/gcc/tree-ssa-math-opts.cc
> +++ b/gcc/tree-ssa-math-opts.cc
> @@ -1495,7 +1495,7 @@ powi_cost (HOST_WIDE_INT n)
>
> static tree
> powi_as_mults_1 (gimple_stmt_iterator *gsi, location_t loc, tree type,
> - HOST_WIDE_INT n, tree *cache)
> + unsigned HOST_WIDE_INT n, tree *cache)
> {
> tree op0, op1, ssa_target;
> unsigned HOST_WIDE_INT digit;
> @@ -1548,7 +1548,7 @@ powi_as_mults (gimple_stmt_iterator *gsi, location_t
> loc,
> memset (cache, 0, sizeof (cache));
> cache[1] = arg0;
>
> - result = powi_as_mults_1 (gsi, loc, type, (n < 0) ? -n : n, cache);
> + result = powi_as_mults_1 (gsi, loc, type, absu_hwi (n), cache);
> if (n >= 0)
> return result;
Thank you, I missed that "(n < 0) ? -n : n" in the code...
I can confirm the compiler bootstraps, and no longer crashes on the testcase.
I didn't try to run the testsuite.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105431] ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow()
2022-04-29 5:27 [Bug tree-optimization/105431] New: ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow() zsojka at seznam dot cz
` (4 preceding siblings ...)
2022-04-29 8:23 ` zsojka at seznam dot cz
@ 2022-04-29 9:10 ` cvs-commit at gcc dot gnu.org
2022-04-29 9:11 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-29 9:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:44b09adb9bad99dd7e3017c5ecefed7f7c9a1590
commit r13-35-g44b09adb9bad99dd7e3017c5ecefed7f7c9a1590
Author: Richard Biener <rguenther@suse.de>
Date: Fri Apr 29 08:45:48 2022 +0200
tree-optimization/105431 - another overflow in powi handling
This avoids undefined signed overflow when calling powi_as_mults_1.
2022-04-29 Richard Biener <rguenther@suse.de>
PR tree-optimization/105431
* tree-ssa-math-opts.cc (powi_as_mults_1): Make n unsigned.
(powi_as_mults): Use absu_hwi.
(gimple_expand_builtin_powi): Remove now pointless n != -n
check.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105431] ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow()
2022-04-29 5:27 [Bug tree-optimization/105431] New: ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow() zsojka at seznam dot cz
` (5 preceding siblings ...)
2022-04-29 9:10 ` cvs-commit at gcc dot gnu.org
@ 2022-04-29 9:11 ` rguenth at gcc dot gnu.org
2022-05-19 12:47 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-29 9:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail|13.0 |
Known to work| |13.0
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk sofar.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105431] ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow()
2022-04-29 5:27 [Bug tree-optimization/105431] New: ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow() zsojka at seznam dot cz
` (6 preceding siblings ...)
2022-04-29 9:11 ` rguenth at gcc dot gnu.org
@ 2022-05-19 12:47 ` cvs-commit at gcc dot gnu.org
2022-05-19 14:03 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-19 12:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:1e43783b3f3570f59bbe80fe38ba65049fa77a0a
commit r12-8396-g1e43783b3f3570f59bbe80fe38ba65049fa77a0a
Author: Richard Biener <rguenther@suse.de>
Date: Fri Apr 29 08:45:48 2022 +0200
tree-optimization/105431 - another overflow in powi handling
This avoids undefined signed overflow when calling powi_as_mults_1.
2022-04-29 Richard Biener <rguenther@suse.de>
PR tree-optimization/105431
* tree-ssa-math-opts.cc (powi_as_mults_1): Make n unsigned.
(powi_as_mults): Use absu_hwi.
(gimple_expand_builtin_powi): Remove now pointless n != -n
check.
(cherry picked from commit 44b09adb9bad99dd7e3017c5ecefed7f7c9a1590)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105431] ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow()
2022-04-29 5:27 [Bug tree-optimization/105431] New: ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow() zsojka at seznam dot cz
` (7 preceding siblings ...)
2022-05-19 12:47 ` cvs-commit at gcc dot gnu.org
@ 2022-05-19 14:03 ` cvs-commit at gcc dot gnu.org
2022-05-27 13:15 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-19 14:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:16a2fcfe247364088ca9d6d058d870bdfa28b345
commit r11-10020-g16a2fcfe247364088ca9d6d058d870bdfa28b345
Author: Richard Biener <rguenther@suse.de>
Date: Fri Apr 29 08:45:48 2022 +0200
tree-optimization/105431 - another overflow in powi handling
This avoids undefined signed overflow when calling powi_as_mults_1.
2022-04-29 Richard Biener <rguenther@suse.de>
PR tree-optimization/105431
* tree-ssa-math-opts.c (powi_as_mults_1): Make n unsigned.
(powi_as_mults): Use absu_hwi.
(gimple_expand_builtin_powi): Remove now pointless n != -n
check.
(cherry picked from commit 44b09adb9bad99dd7e3017c5ecefed7f7c9a1590)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105431] ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow()
2022-04-29 5:27 [Bug tree-optimization/105431] New: ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow() zsojka at seznam dot cz
` (8 preceding siblings ...)
2022-05-19 14:03 ` cvs-commit at gcc dot gnu.org
@ 2022-05-27 13:15 ` cvs-commit at gcc dot gnu.org
2022-05-27 13:16 ` rguenth at gcc dot gnu.org
2022-10-31 19:57 ` pinskia at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-27 13:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:e41fa23451c965516a37282268231933fd948845
commit r10-10765-ge41fa23451c965516a37282268231933fd948845
Author: Richard Biener <rguenther@suse.de>
Date: Fri Apr 29 08:45:48 2022 +0200
tree-optimization/105431 - another overflow in powi handling
This avoids undefined signed overflow when calling powi_as_mults_1.
2022-04-29 Richard Biener <rguenther@suse.de>
PR tree-optimization/105431
* tree-ssa-math-opts.c (powi_as_mults_1): Make n unsigned.
(powi_as_mults): Use absu_hwi.
(gimple_expand_builtin_powi): Remove now pointless n != -n
check.
(cherry picked from commit 44b09adb9bad99dd7e3017c5ecefed7f7c9a1590)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105431] ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow()
2022-04-29 5:27 [Bug tree-optimization/105431] New: ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow() zsojka at seznam dot cz
` (9 preceding siblings ...)
2022-05-27 13:15 ` cvs-commit at gcc dot gnu.org
@ 2022-05-27 13:16 ` rguenth at gcc dot gnu.org
2022-10-31 19:57 ` pinskia at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27 13:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |10.3.0, 11.2.0
Known to work| |10.3.1, 11.2.1
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/105431] ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow()
2022-04-29 5:27 [Bug tree-optimization/105431] New: ICE: SIGSEGV in powi_as_mults_1 (tree-ssa-math-opts.cc:1512) with -Ofast and __builtin_pow() zsojka at seznam dot cz
` (10 preceding siblings ...)
2022-05-27 13:16 ` rguenth at gcc dot gnu.org
@ 2022-10-31 19:57 ` pinskia at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-31 19:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.4
^ permalink raw reply [flat|nested] 13+ messages in thread