xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/constant-combines.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-unknown-unknown"
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workerdefine void @PR22524({ float, float }* %arg) {
7*9880d681SAndroid Build Coastguard Worker; Check that we can materialize the zero constants we store in two places here,
8*9880d681SAndroid Build Coastguard Worker; and at least form a legal store of the floating point value at the end.
9*9880d681SAndroid Build Coastguard Worker; The DAG combiner at one point contained bugs that given enough permutations
10*9880d681SAndroid Build Coastguard Worker; would incorrectly form an illegal operation for the last of these stores when
11*9880d681SAndroid Build Coastguard Worker; it folded it to a zero too late to legalize the zero store operation. If this
12*9880d681SAndroid Build Coastguard Worker; ever starts forming a zero store instead of movss, the test case has stopped
13*9880d681SAndroid Build Coastguard Worker; being useful.
14*9880d681SAndroid Build Coastguard Worker;
15*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: PR22524:
16*9880d681SAndroid Build Coastguard Workerentry:
17*9880d681SAndroid Build Coastguard Worker  %0 = getelementptr inbounds { float, float }, { float, float }* %arg,  i32 0, i32 1
18*9880d681SAndroid Build Coastguard Worker  store float 0.000000e+00, float* %0, align 4
19*9880d681SAndroid Build Coastguard Worker; CHECK: movl $0, 4(%rdi)
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr inbounds { float, float }, { float, float }* %arg, i64 0,  i32 0
22*9880d681SAndroid Build Coastguard Worker  %2 = bitcast float* %1 to i64*
23*9880d681SAndroid Build Coastguard Worker  %3 = load i64, i64* %2, align 8
24*9880d681SAndroid Build Coastguard Worker  %4 = trunc i64 %3 to i32
25*9880d681SAndroid Build Coastguard Worker  %5 = lshr i64 %3, 32
26*9880d681SAndroid Build Coastguard Worker  %6 = trunc i64 %5 to i32
27*9880d681SAndroid Build Coastguard Worker  %7 = bitcast i32 %6 to float
28*9880d681SAndroid Build Coastguard Worker  %8 = fmul float %7, 0.000000e+00
29*9880d681SAndroid Build Coastguard Worker  %9 = bitcast float* %1 to i32*
30*9880d681SAndroid Build Coastguard Worker  store i32 %6, i32* %9, align 4
31*9880d681SAndroid Build Coastguard Worker; CHECK: movl $0, (%rdi)
32*9880d681SAndroid Build Coastguard Worker  store float %8, float* %0, align 4
33*9880d681SAndroid Build Coastguard Worker; CHECK: movss %{{.*}}, 4(%rdi)
34*9880d681SAndroid Build Coastguard Worker  ret void
35*9880d681SAndroid Build Coastguard Worker}
36