[Bug rtl-optimization/110867] [14 Regression] ICE in combine after 7cdd0860949c6c3232e6cff1d7ca37bb5234074c

2023-10-01 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110867

Xi Ruoyao  changed:

   What|Removed |Added

 Resolution|DUPLICATE   |FIXED

--- Comment #12 from Xi Ruoyao  ---
Mistakenly marked it as dup.

[Bug rtl-optimization/110867] [14 Regression] ICE in combine after 7cdd0860949c6c3232e6cff1d7ca37bb5234074c

2023-10-01 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110867

Xi Ruoyao  changed:

   What|Removed |Added

 Resolution|--- |DUPLICATE
 Status|UNCONFIRMED |RESOLVED

--- Comment #11 from Xi Ruoyao  ---
The patch is pushed at r14-4355.

*** This bug has been marked as a duplicate of bug 110939 ***

[Bug rtl-optimization/110867] [14 Regression] ICE in combine after 7cdd0860949c6c3232e6cff1d7ca37bb5234074c

2023-08-13 Thread prathamesh3492 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110867

--- Comment #10 from prathamesh3492 at gcc dot gnu.org ---
(In reply to Stefan Schulze Frielinghaus from comment #9)
> It looks like as if the first fix didn't entirely solve the problem.  It
> turns out that the normal form of const_int is not always met.  Before
> releasing a new patch, could you test it first in order to make sure that I
> do not break bootstrapping again.  I already gave it a try against the
> reproducer but would like to make sure that the whole bootstrap is
> successful.

Hi Stefan,
I bootstrapped+tested your patch from Comment 8 on arm, and it seems OK.

Thanks,
Prathamesh

[Bug rtl-optimization/110867] [14 Regression] ICE in combine after 7cdd0860949c6c3232e6cff1d7ca37bb5234074c

2023-08-10 Thread stefansf at linux dot ibm.com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110867

--- Comment #9 from Stefan Schulze Frielinghaus  
---
It looks like as if the first fix didn't entirely solve the problem.  It turns
out that the normal form of const_int is not always met.  Before releasing a
new patch, could you test it first in order to make sure that I do not break
bootstrapping again.  I already gave it a try against the reproducer but would
like to make sure that the whole bootstrap is successful.

[Bug rtl-optimization/110867] [14 Regression] ICE in combine after 7cdd0860949c6c3232e6cff1d7ca37bb5234074c

2023-08-10 Thread stefansf at linux dot ibm.com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110867

--- Comment #8 from Stefan Schulze Frielinghaus  
---
Created attachment 55716
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55716=edit
Really fix narrow comparison

[Bug rtl-optimization/110867] [14 Regression] ICE in combine after 7cdd0860949c6c3232e6cff1d7ca37bb5234074c

2023-08-08 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110867

Xi Ruoyao  changed:

   What|Removed |Added

 CC||xry111 at gcc dot gnu.org

--- Comment #7 from Xi Ruoyao  ---
Can we close it as fixed now?

[Bug rtl-optimization/110867] [14 Regression] ICE in combine after 7cdd0860949c6c3232e6cff1d7ca37bb5234074c

2023-08-08 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110867

Xi Ruoyao  changed:

   What|Removed |Added

 CC||panchenghui at loongson dot cn

--- Comment #6 from Xi Ruoyao  ---
*** Bug 110939 has been marked as a duplicate of this bug. ***

[Bug rtl-optimization/110867] [14 Regression] ICE in combine after 7cdd0860949c6c3232e6cff1d7ca37bb5234074c

2023-08-02 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110867

--- Comment #5 from CVS Commits  ---
The master branch has been updated by Stefan Schulze Frielinghaus
:

https://gcc.gnu.org/g:41ef5a34161356817807be3a2e51fbdbe575ae85

commit r14-2932-g41ef5a34161356817807be3a2e51fbdbe575ae85
Author: Stefan Schulze Frielinghaus 
Date:   Wed Aug 2 21:43:22 2023 +0200

rtl-optimization/110867 Fix narrow comparison of memory and constant

In certain cases a constant may not fit into the mode used to perform a
comparison.  This may be the case for sign-extended constants which are
used during an unsigned comparison as e.g. in

(set (reg:CC 100 cc)
(compare:CC (mem:SI (reg/v/f:SI 115 [ a ]) [1 *a_4(D)+0 S4 A64])
(const_int -2147483648 [0x8000])))

Fixed by ensuring that the constant fits into comparison mode.

Furthermore, on some targets as e.g. sparc the constant used in a
comparison is chopped off before combine which leads to failing test
cases (see PR 110869).  Fixed by not requiring that the source mode has
to be DImode, and excluding sparc from the last two test cases entirely
since there the constant cannot be further reduced.

gcc/ChangeLog:

PR rtl-optimization/110867
* combine.cc (simplify_compare_const): Try the optimization only
in case the constant fits into the comparison mode.

gcc/testsuite/ChangeLog:

PR rtl-optimization/110869
* gcc.dg/cmp-mem-const-1.c: Relax mode for constant.
* gcc.dg/cmp-mem-const-2.c: Relax mode for constant.
* gcc.dg/cmp-mem-const-3.c: Relax mode for constant.
* gcc.dg/cmp-mem-const-4.c: Relax mode for constant.
* gcc.dg/cmp-mem-const-5.c: Exclude sparc since here the
constant is already reduced.
* gcc.dg/cmp-mem-const-6.c: Exclude sparc since here the
constant is already reduced.

[Bug rtl-optimization/110867] [14 Regression] ICE in combine after 7cdd0860949c6c3232e6cff1d7ca37bb5234074c

2023-08-02 Thread stefansf at linux dot ibm.com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110867

--- Comment #4 from Stefan Schulze Frielinghaus  
---
Thanks for testing so quickly :)

I've send a patch for review:

https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626075.html

[Bug rtl-optimization/110867] [14 Regression] ICE in combine after 7cdd0860949c6c3232e6cff1d7ca37bb5234074c

2023-08-01 Thread prathamesh3492 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110867

--- Comment #3 from prathamesh3492 at gcc dot gnu.org ---
(In reply to prathamesh3492 from comment #2)
> (In reply to Stefan Schulze Frielinghaus from comment #1)
> > The optimization introduced by r14-2879-g7cdd0860949c6c hits during
> > combination of insn
> > 
> > (insn 31 3 32 2 (set (reg:SI 118 [ _1 ])
> > (mem:SI (reg/v/f:SI 115 [ a ]) [1 *a_4(D)+0 S4 A64])) "t.c":15:7 758
> > {*arm_movsi_vfp}
> >  (nil))
> > 
> > and
> > 
> > (insn 9 32 10 2 (set (reg:CC 100 cc)
> > (compare:CC (reg:SI 118 [ _1 ])
> > (const_int -2147483648 [0x8000]))) "t.c":15:6 272
> > {*arm_cmpsi_insn}
> >  (nil))
> > 
> > The idea of r14-2879-g7cdd0860949c6c is to get rid of large constants while
> > performing an unsigned comparison.  In this case it looks like a 32-bit
> > constant is sign-extended into a 64-bit constant and then a 32-bit
> > comparison is done.  While writing the optimization I always assumed that
> > the constant does fit into int_mode which is apparently not the case here. 
> > Thus one possible solution would be to simply bail out in those cases:
> > 
> > diff --git a/gcc/combine.cc b/gcc/combine.cc
> > index 0d99fa541c5..e46d202d0a7 100644
> > --- a/gcc/combine.cc
> > +++ b/gcc/combine.cc
> > @@ -11998,11 +11998,15 @@ simplify_compare_const (enum rtx_code code,
> > machine_mode mode,
> >   x0 >= 0x40.  */
> >if ((code == LEU || code == LTU || code == GEU || code == GTU)
> >&& is_a  (GET_MODE (op0), _mode)
> > +  && HWI_COMPUTABLE_MODE_P (int_mode)
> >&& MEM_P (op0)
> >&& !MEM_VOLATILE_P (op0)
> >/* The optimization makes only sense for constants which are big
> > enough
> >  so that we have a chance to chop off something at all.  */
> >&& (unsigned HOST_WIDE_INT) const_op > 0xff
> > +  /* Bail out, if the constant does not fit into INT_MODE.  */
> > +  && (unsigned HOST_WIDE_INT) const_op
> > +< ((HOST_WIDE_INT_1U << (GET_MODE_PRECISION (int_mode) - 1) << 1) -
> > 1)
> >/* Ensure that we do not overflow during normalization.  */
> >&& (code != GTU || (unsigned HOST_WIDE_INT) const_op <
> > HOST_WIDE_INT_M1U))
> >  {
> > 
> > Does this resolve the problem for you?
> 
> Yes, it worked thanks! I will do a full bootstrap+test with your fix and let
> you know the results.
Bootstrap+testing works fine with your fix. Thanks!
> 
> Thanks,
> Prathamesh

[Bug rtl-optimization/110867] [14 Regression] ICE in combine after 7cdd0860949c6c3232e6cff1d7ca37bb5234074c

2023-08-01 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110867

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||build, ice-on-valid-code
Summary|ICE in combine after|[14 Regression] ICE in
   |7cdd0860949c6c3232e6cff1d7c |combine after
   |a37bb5234074c   |7cdd0860949c6c3232e6cff1d7c
   ||a37bb5234074c
   Target Milestone|--- |14.0