Skip to content

Poor code generated for whole-vector shifts #10409

@llvmbot

Description

@llvmbot
Bugzilla Link 10037
Resolution WONTFIX
Resolved on May 31, 2011 11:09
Version 2.9
OS Linux
Reporter LLVM Bugzilla Contributor
CC @sunfishcode

Extended Description

Consider this:

define <4 x i32> @​lshr(<4 x i32> %x) {
%a = bitcast <4 x i32> %x to i128
%b = lshr i128 %a, 32
%c = bitcast i128 %b to <4 x i32>
ret <4 x i32> %c
}

it codegens to:

    movd    %xmm0, %rcx
    pextrq  $1, %xmm0, %rax
    shrdq   $32, %rax, %rcx
    movd    %rcx, %xmm0
    shrq    $32, %rax
    movd    %rax, %xmm1
    punpcklqdq      %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]

however it could codegen to a simple
psrldq
since the shift is by a multiple of 8.

The best way to solve this might be to turn this construct into a shufflevector
at the IR level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillawontfixIssue is real, but we can't or won't fix it. Not invalid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions