This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/69569] unnecessary branches on an if followed by a switch
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 21 Aug 2016 22:31:02 +0000
- Subject: [Bug tree-optimization/69569] unnecessary branches on an if followed by a switch
- Authentication-results: sourceware.org; auth=none
- Auto-submitted: auto-generated
- References: <bug-69569-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69569
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2016-08-21
Component|rtl-optimization |tree-optimization
Ever confirmed|0 |1
Severity|normal |enhancement
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is optimized for -O2 and above on aarch64-linux-gnu just fine:
For GCC 7:
baz:
cmp w0, 2
bgt .L1
bne .L1
b foo
.p2align 3
.L1:
mov w0, 77
ret
--- CUT ----
For GCC 5.4:
baz:
cmp w0, 2
ble .L7
.L2:
mov w0, 77
ret
.p2align 3
.L7:
bne .L2
b foo
---- CUT ----
I suspect the issue for -O1 is that we don't change the switch into an if
statement when we only have two cases.