xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/extractelement-legalization-cycle.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; When the extractelement is converted to a load the store can be re-used.
4*9880d681SAndroid Build Coastguard Worker; This will, however, introduce a cycle into the selection DAG (the load
5*9880d681SAndroid Build Coastguard Worker; of the extractelement index is dependent on the store, and so after the
6*9880d681SAndroid Build Coastguard Worker; conversion it becomes dependent on the new load, which is dependent on
7*9880d681SAndroid Build Coastguard Worker; the index).  Make sure we skip the store, and conservatively instead
8*9880d681SAndroid Build Coastguard Worker; use a store to the stack.
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdefine float @foo(i32* %i, <4 x float>* %v) {
11*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo:
12*9880d681SAndroid Build Coastguard Worker; CHECK:    movaps %xmm0, -[[OFFSET:[0-9]+]](%rsp)
13*9880d681SAndroid Build Coastguard Worker; CHECK:    movss -[[OFFSET]](%rsp,{{.*}}), %xmm0 {{.*}}
14*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    retq
15*9880d681SAndroid Build Coastguard Worker  %1 = load <4 x float>, <4 x float>* %v, align 16
16*9880d681SAndroid Build Coastguard Worker  %mul = fmul <4 x float> %1, %1
17*9880d681SAndroid Build Coastguard Worker  store <4 x float> %mul, <4 x float>* %v, align 16
18*9880d681SAndroid Build Coastguard Worker  %2 = load i32, i32* %i, align 4
19*9880d681SAndroid Build Coastguard Worker  %vecext = extractelement <4 x float> %mul, i32 %2
20*9880d681SAndroid Build Coastguard Worker  ret float %vecext
21*9880d681SAndroid Build Coastguard Worker}
22