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

--- Comment #2 from Paolo Bonzini <bonzini at gnu dot org> ---
Yes, until combine there is the equivalent of

        addl    $512, %ecx                ;; 4
        andl    $-8, %ecx                 ;; 4.5
        shrl    $3, %ecx                  ;; 5

and combine is able to merge insn 4.5 and 5 into just the shrl.

However, this optimization would require combine to merge together a lot of
instructions.  Even with some munging of the expander, the best you could get
is probably four:

        leaq    8(%rdi), %rdi       ;;     rdi = b' = b + 8
        leaq    -8(%rdi), %rcx      ;; i1: rcx = b' - 8
        andq    $-8, %rdi           ;; i2: rdi = b' & -8
        subq    %rdi, %rcx          ;; i3: rcx = b' - 8 - (b' & -8) = (b' & 7)
- 8
        shrl    $3, %ecx            ;; i4: rcx = -1
        addl    $32, %ecx           ;;     rcx = 31

The constant isn't visible with a subset of them.

Reply via email to