xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/trunc-store.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=x86-64 | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; With optimization at O2 we actually get the legalized function optimized
4*9880d681SAndroid Build Coastguard Worker; away through legalization and stack coloring, but check that we do all of
5*9880d681SAndroid Build Coastguard Worker; that here and don't crash during legalization.
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; Original program:
8*9880d681SAndroid Build Coastguard Worker; typedef enum { A, B, C, D } P;
9*9880d681SAndroid Build Coastguard Worker; struct { P x[2]; } a;
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Worker; void fn2();
12*9880d681SAndroid Build Coastguard Worker; void fn1() {
13*9880d681SAndroid Build Coastguard Worker;   int b;
14*9880d681SAndroid Build Coastguard Worker;   unsigned c;
15*9880d681SAndroid Build Coastguard Worker;   for (;; c++) {
16*9880d681SAndroid Build Coastguard Worker;     fn2();
17*9880d681SAndroid Build Coastguard Worker;     unsigned n;
18*9880d681SAndroid Build Coastguard Worker;     for (; c; c++) {
19*9880d681SAndroid Build Coastguard Worker;       b = a.x[c] == A || a.x[c] == B || a.x[c] == D;
20*9880d681SAndroid Build Coastguard Worker;       if (b) n++;
21*9880d681SAndroid Build Coastguard Worker;     }
22*9880d681SAndroid Build Coastguard Worker;     if (n)
23*9880d681SAndroid Build Coastguard Worker;	for (;;)
24*9880d681SAndroid Build Coastguard Worker;	  ;
25*9880d681SAndroid Build Coastguard Worker;   }
26*9880d681SAndroid Build Coastguard Worker; }
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Workerdefine void @fn1() {
29*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: fn1
30*9880d681SAndroid Build Coastguard Worker; CHECK: movb	$0, {{.*}}(%rsp)
31*9880d681SAndroid Build Coastguard Worker; CHECK: cmpq	$8, %rax
32*9880d681SAndroid Build Coastguard Workerfor.cond:
33*9880d681SAndroid Build Coastguard Worker  br label %vector.body
34*9880d681SAndroid Build Coastguard Worker
35*9880d681SAndroid Build Coastguard Workervector.body:                                      ; preds = %vector.body, %for.cond
36*9880d681SAndroid Build Coastguard Worker  %x42 = bitcast <4 x i4> zeroinitializer to i16
37*9880d681SAndroid Build Coastguard Worker  %x43 = icmp ne i16 %x42, 0
38*9880d681SAndroid Build Coastguard Worker  %x44 = select i1 %x43, i32 undef, i32 0
39*9880d681SAndroid Build Coastguard Worker  %x72 = bitcast <4 x i1> zeroinitializer to i4
40*9880d681SAndroid Build Coastguard Worker  %x73 = icmp ne i4 %x72, 0
41*9880d681SAndroid Build Coastguard Worker  %x74 = select i1 %x73, i32 %x44, i32 undef
42*9880d681SAndroid Build Coastguard Worker  %x84 = select i1 undef, i32 undef, i32 %x74
43*9880d681SAndroid Build Coastguard Worker  %x88 = icmp eq i64 undef, 8
44*9880d681SAndroid Build Coastguard Worker  br i1 %x88, label %middle.block, label %vector.body
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Workermiddle.block:                                     ; preds = %vector.body
47*9880d681SAndroid Build Coastguard Worker  %0 = select i1 undef, i32 undef, i32 %x84
48*9880d681SAndroid Build Coastguard Worker  ret void
49*9880d681SAndroid Build Coastguard Worker}
50