xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/fma-do-not-commute.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -fp-contract=fast -mattr=+fma -disable-cgp < %s -o - | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; Check that the 2nd and 3rd arguments of fmaXXX231 reg1, reg2, mem3 are not commuted.
3*9880d681SAndroid Build Coastguard Worker; <rdar://problem/16800495>
4*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-apple-macosx"
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test1:
8*9880d681SAndroid Build Coastguard Worker; %arg lives in xmm0 and it shouldn't be redefined until it is used in the FMA.
9*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{.*}}, %xmm0
10*9880d681SAndroid Build Coastguard Worker; %addr lives in rdi.
11*9880d681SAndroid Build Coastguard Worker; %addr2 lives in rsi.
12*9880d681SAndroid Build Coastguard Worker; CHECK: vmovss (%rsi), [[ADDR2:%xmm[0-9]+]]
13*9880d681SAndroid Build Coastguard Worker; The assembly syntax is in the reverse order.
14*9880d681SAndroid Build Coastguard Worker; CHECK: vfmadd231ss (%rdi), [[ADDR2]], %xmm0
15*9880d681SAndroid Build Coastguard Workerdefine void @test1(float* %addr, float* %addr2, float %arg) {
16*9880d681SAndroid Build Coastguard Workerentry:
17*9880d681SAndroid Build Coastguard Worker  br label %loop
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Workerloop:
20*9880d681SAndroid Build Coastguard Worker  %sum0 = phi float [ %fma, %loop ], [ %arg, %entry ]
21*9880d681SAndroid Build Coastguard Worker  %addrVal = load float, float* %addr, align 4
22*9880d681SAndroid Build Coastguard Worker  %addr2Val = load float, float* %addr2, align 4
23*9880d681SAndroid Build Coastguard Worker  %fmul = fmul float %addrVal, %addr2Val
24*9880d681SAndroid Build Coastguard Worker  %fma = fadd float %sum0, %fmul
25*9880d681SAndroid Build Coastguard Worker  br i1 true, label %exit, label %loop
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerexit:
28*9880d681SAndroid Build Coastguard Worker  store float %fma, float* %addr, align 4
29*9880d681SAndroid Build Coastguard Worker  ret void
30*9880d681SAndroid Build Coastguard Worker}
31