-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Closed
Labels
good first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contributellvm:SelectionDAGSelectionDAGISel as wellSelectionDAGISel as well
Description
https://zig.godbolt.org/z/36WWT1Kes
define <4 x i32> @doit() {
%res = call <4 x i32> @llvm.fshl.v4i32(<4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32> <i32 8, i32 9, i32 10, i32 11>)
ret <4 x i32> %res
}
llc -matr=+avx2
vmovaps .LCPI0_0(%rip), %xmm0 # xmm0 = [0,512,2048,6144]
retq
llc -mattr=+avx512vl,+avx512vbmi2
doit: # @doit
vpmovsxbd .LCPI0_3(%rip), %xmm1 # xmm1 = [4,5,6,7]
vpmovsxbd .LCPI0_4(%rip), %xmm0 # xmm0 = [0,1,2,3]
vpshldvd .LCPI0_2(%rip), %xmm1, %xmm0
retq
AVX2 manages to constant fold fshl/fshr only because we expand to regular shifts, AVX512VBMI2 targets have legal funnel shift instructions and have no opportunity to constant fold.
FoldConstantArithmetic only attempts to constant fold unary/binary scalars, but it shouldn't be difficult to handle trinary scalar integers as well for FSHL/R.
Metadata
Metadata
Assignees
Labels
good first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contributellvm:SelectionDAGSelectionDAGISel as wellSelectionDAGISel as well