public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101701] GCC optimization and code generation for if-else chains vs ternary chains vs a switch Date: Tue, 03 Aug 2021 09:25:00 +0000 [thread overview] Message-ID: <bug-101701-4-RcWLZ78lhN@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-101701-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101701 Martin Liška <marxin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #2) > So the problem here is iftoswitch should ignore if it is profitable to > convert the ifs to a switch statement (unless there are only two ifs) and > then allow the switchlower pass to lower the switch again. This was my original intention, but Jakub wanted to make the if-to-switch transformation only conditionally based on the ability to make a jump table or a bit-test. Reason is that some optimization passes work only on series of gimple conditions. > > So x86 we get: > ;; Canonical GIMPLE case clusters: 1 2 3 4 > For foo > and then for bar: > ;; Canonical GIMPLE case clusters: 1 2 3 4 > ;; BT can be built: BT(values:4 comparisons:8 range:4 density: 200.00%):1-4 > /app/example.cpp:10:21: optimized: Condition chain with 4 BBs transformed > into a switch statement. In my case, it's not transformed as we do JT at least for 5 cases: unsigned int default_case_values_threshold (void) { return (targetm.have_casesi () ? 4 : 5); } That's why you see a different codegen on ARM target.
prev parent reply other threads:[~2021-08-03 9:25 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-30 23:37 [Bug c++/101701] New: " llvm at rifkin dot dev 2021-07-30 23:39 ` [Bug tree-optimization/101701] " pinskia at gcc dot gnu.org 2021-07-30 23:48 ` pinskia at gcc dot gnu.org 2021-07-30 23:50 ` pinskia at gcc dot gnu.org 2021-07-30 23:53 ` llvm at rifkin dot dev 2021-08-03 9:25 ` marxin at gcc dot gnu.org [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-101701-4-RcWLZ78lhN@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).