[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-19 Thread wilson at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 Jim Wilson changed: What|Removed |Added Status|NEW |RESOLVED Resolution|---

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-18 Thread kito at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #26 from Kito Cheng --- Author: kito Date: Thu Sep 19 06:38:23 2019 New Revision: 275929 URL: https://gcc.gnu.org/viewcvs?rev=275929&root=gcc&view=rev Log: RISC-V: Fix bad insn splits with paradoxical subregs. Shifting by more than

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-05 Thread wilson at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #25 from Jim Wilson --- Author: wilson Date: Thu Sep 5 20:32:55 2019 New Revision: 275444 URL: https://gcc.gnu.org/viewcvs?rev=275444&root=gcc&view=rev Log: RISC-V: Fix bad insn splits with paradoxical subregs. Shifting by more tha

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-05 Thread segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #24 from Segher Boessenkool --- (clobber of a match_operand I mean, sigh).

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-05 Thread segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #23 from Segher Boessenkool --- If a splitter wants a new register during combine, it should do a match_scratch for that. This is documented. You do not normally get new registers during combine. combine cannot really handle those.

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-05 Thread wilson at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #22 from Jim Wilson --- > First of all, I think you need to use :DI instead of :GPR for the last > define_split, as it shouldn't be iterated with. Yes, sloppy copy paste. I will fix before committing. > Second, doesn't this mean th

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-05 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 Jakub Jelinek changed: What|Removed |Added CC||segher at gcc dot gnu.org --- Comment #2

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-04 Thread wilson at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #20 from Jim Wilson --- Created attachment 46830 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46830&action=edit proposed patch to fix paradoxical reg in splitter problem I get better code size with this alternative patch. I

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-04 Thread wilson at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #19 from Jim Wilson --- I did cross toolchain builds and checks for rv32i/newlib and rv64gc/glibc. There were no regressions. Since the splitters exist to reduce code size, I looked at the libc and libstdc++ sizes with and without t

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-04 Thread wilson at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #18 from Jim Wilson --- I was willing to write a patch, I just needed a day to catch up as I'm hopelessly overloaded with work. But since Jakub wrote one, it looks right to me, and I think we should use that. I'm not sure exactly wh

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-04 Thread kito at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #17 from Kito Cheng --- Hi Jakub: Thanks your patch, I've run with gcc testsuite and no new fails, and I am ruining more gcc testsuite regression with different arch/abi combination for that. I am amazing that seems like RISC-V is f

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-04 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #16 from Jakub Jelinek --- Created attachment 46809 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46809&action=edit gcc10-pr91635.patch If you want full patch from me, here it is, but as I said I can't easily test it (I don't

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-04 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #15 from Jakub Jelinek --- Then gen_rtx_REG (mode, REGNO (SUBREG_REG (x))) case I meant only in case some splitter would be required for proper operation rather than just being an optimization. If they are all an optimization, the !p

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-03 Thread zsojka at seznam dot cz
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #14 from Zdenek Sojka --- Thank you all for looking into this! I can't provide testcases for other issues, if they exist at all, since I am hitting the first one too often. If you fix only the first issue, there is a chance the other

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-03 Thread wilson at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #13 from Jim Wilson --- I see 5 broken patterns which matches the list already given. The four testcases are all triggering on the same splitter, which is the first define_split, lshrsi3_zero_extend_3+1. The second define_split, lsh

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-03 Thread kito at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #12 from Kito Cheng --- Hi Zdenek: I can reproduce for all new 3 testcases, it seems like cause by same issue, thanks you provide more testcase for that!

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-03 Thread zsojka at seznam dot cz
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #11 from Zdenek Sojka --- Created attachment 46803 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46803&action=edit another testcase

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-03 Thread zsojka at seznam dot cz
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #10 from Zdenek Sojka --- Created attachment 46802 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46802&action=edit another testcase

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-03 Thread zsojka at seznam dot cz
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #9 from Zdenek Sojka --- Created attachment 46801 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46801&action=edit another testcase

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-03 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #8 from Jakub Jelinek --- Certainly both register_operand predicate as well as the usual register constraints don't rule out subregs even after reload. can_create_pseudo_p () is false after reload of course. In theory, what you could

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-03 Thread kito at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #7 from Kito Cheng --- Hi Jakub: > that doesn't mean paradoxical subregs can't appear there, just it will be > less likely. Does it mean paradoxical subregs will appear during intermediate result even after reload, so for such spli

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-03 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #6 from Jakub Jelinek --- Other problematic splitters are zero_extendsidi2, zero_extendhi2, extend2, dunno if I haven't missed something else. While they are all post-reload splitters, that doesn't mean paradoxical subregs can't appe

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-03 Thread kito at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #5 from Kito Cheng --- Hi Zdenek: Could you share more testcase? I've a patch is based on Jakub's one. Thanks :)

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-03 Thread zsojka at seznam dot cz
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #4 from Zdenek Sojka --- (In reply to Jakub Jelinek from comment #3) > Looks like a backend bug to me. ... > fixes this, but I don't have a way to test riscv, plus the backend has > several similar problems elsewhere. I can provide s

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-02 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 Jakub Jelinek changed: What|Removed |Added CC||andrew at sifive dot com,

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow() and shifts

2019-09-02 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 Jakub Jelinek changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed|

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow()

2019-09-02 Thread zsojka at seznam dot cz
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 --- Comment #2 from Zdenek Sojka --- (In reply to Jakub Jelinek from comment #1) > Can't reproduce. > I get: > foo: > not a4,a0 > lui a5,%hi(b) > sllia0,a0,17 > sh a4,%lo(b)(a5) > srlia

[Bug target/91635] wrong code at -O2 with __builtin_add_overflow()

2019-09-02 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91635 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #1