Issue |
153612
|
Summary |
[DAG] SelectionDAG::FoldConstantArithmetic - failure to constant fold ISD::FSHL/FSHR nodes
|
Labels |
good first issue,
llvm:SelectionDAG
|
Assignees |
|
Reporter |
RKSimon
|
https://zig.godbolt.org/z/36WWT1Kes
```ll
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
```asm
vmovaps .LCPI0_0(%rip), %xmm0 # xmm0 = [0,512,2048,6144]
retq
```
llc -mattr=+avx512vl,+avx512vbmi2
```asm
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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs