This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rtl-optimization/78447] New: [7 Regression] wrong code when combine changes shifts by << 5 and >> 15 to >> 10 at -O


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78447

            Bug ID: 78447
           Summary: [7 Regression] wrong code when combine changes shifts
                    by << 5 and >> 15 to >> 10 at -O
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu
             Build: x86_64-pc-linux-gnu

Created attachment 40099
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40099&action=edit
reduced testcase

Output:
$ x86_64-pc-linux-gnu-gcc -O testcase.c
$ ./a.out
Aborted

$ x86_64-pc-linux-gnu-gcc -v           
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-242583-checking-yes-rtl-df-extra-nobootstrap-nographite-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--disable-bootstrap --without-cloog --without-ppl --without-isl
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-242583-checking-yes-rtl-df-extra-nobootstrap-nographite-amd64
Thread model: posix
gcc version 7.0.0 20161118 (experimental) (GCC) 


Before .combine:
...
(insn 9 8 10 2 (parallel [
            (set (reg:SI 108)
                (ashift:SI (reg/v:SI 105 [ xD.1799 ])
                    (const_int 5 [0x5])))
            (clobber (reg:CC 17 flags))
        ]) "testcase.c":13 529 {*ashlsi3_1}
     (expr_list:REG_DEAD (reg/v:SI 105 [ xD.1799 ])
        (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil))))
...

(insn 11 10 12 2 (parallel [
            (set (reg:HI 110)
                (lshiftrt:HI (subreg:HI (reg:SI 109) 0)
                    (const_int 15 [0xf])))
            (clobber (reg:CC 17 flags))
        ]) "testcase.c":15 572 {*lshrhi3_1}
     (expr_list:REG_DEAD (reg:SI 109)
        (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil))))
(insn 12 11 13 2 (set (reg:QI 92 [ _11 ])
        (subreg:QI (reg:HI 110) 0)) "testcase.c":15 85 {*movqi_internal}
     (expr_list:REG_DEAD (reg:HI 110)
        (nil)))
...


.combine shows:
...
Trying 9, 11 -> 12:
...
Successfully matched this instruction:
(set (reg:SI 110)
    (lshiftrt:SI (reg/v:SI 105 [ xD.1799 ])
        (const_int 10 [0xa])))
Successfully matched this instruction:
(set (subreg:SI (reg:QI 92 [ _11 ]) 0)
    (and:SI (reg:SI 110)
        (const_int 255 [0xff])))
allowing combination of insns 9, 11 and 12
original costs 4 + 4 + 4 = 12
replacement costs 4 + 4 = 8


Which is probably wrong.


Tested revisions:
r242657 - FAIL
r242583 - FAIL
r242510 - FAIL
r242408 - OK

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]