public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101991] New: bit_and or bit_ior with an invariant inside loop is not pulled out of the loop Date: Fri, 20 Aug 2021 02:35:48 +0000 [thread overview] Message-ID: <bug-101991-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101991 Bug ID: 101991 Summary: bit_and or bit_ior with an invariant inside loop is not pulled out of the loop Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take these two functions: int f(int t, int d, int e) { int r = d; for(int i = 0; i < t; i++) r &= e; return r; } int f1(int t, int d, int e) { int r = d; if (0 < t) r &= e; return r; } They should produce the same code. Right now f still has a loop in it. The same is true with bit_ior. Note the code is really bad when the vectorizer comes around really. I forgot how I found this either. Note clang/ICC also vectorize this code crappily. clang on the trunk almost gets there but still has a loop: movl %esi, %eax xorl %esi, %esi testl %edi, %edi cmovgl %edi, %esi jle .LBB0_6 # %bb.1: leal -1(%rsi), %edi movl %esi, %ecx andl $7, %ecx cmpl $7, %edi jb .LBB0_4 # %bb.2: andl $-8, %esi negl %esi .p2align 4, 0x90 .LBB0_3: # =>This Inner Loop Header: Depth=1 addl $8, %esi jne .LBB0_3 .LBB0_4: andl %edx, %eax testl %ecx, %ecx je .LBB0_6 .p2align 4, 0x90 .LBB0_5: # =>This Inner Loop Header: Depth=1 addl $-1, %ecx jne .LBB0_5 .LBB0_6: retq
next reply other threads:[~2021-08-20 2:35 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-20 2:35 pinskia at gcc dot gnu.org [this message] 2021-08-20 8:45 ` [Bug tree-optimization/101991] " rguenth at gcc dot gnu.org 2022-05-26 8:29 ` pinskia at gcc dot gnu.org 2022-09-22 2:06 ` lingling.kong7 at gmail dot com 2022-10-22 22:30 ` pinskia at gcc dot gnu.org
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-101991-4@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).