xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/norex-subreg.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -O0 < %s -verify-machineinstrs
2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -verify-machineinstrs
3*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-apple-macosx10.7"
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker; This test case extracts a sub_8bit_hi sub-register:
6*9880d681SAndroid Build Coastguard Worker;
7*9880d681SAndroid Build Coastguard Worker;	%R8B<def> = COPY %BH, %EBX<imp-use,kill>
8*9880d681SAndroid Build Coastguard Worker;	%ESI<def> = MOVZX32_NOREXrr8 %R8B<kill>
9*9880d681SAndroid Build Coastguard Worker;
10*9880d681SAndroid Build Coastguard Worker; The register allocation above is invalid, %BH can only be encoded without an
11*9880d681SAndroid Build Coastguard Worker; REX prefix, so the destination register must be GR8_NOREX.  The code above
12*9880d681SAndroid Build Coastguard Worker; triggers an assertion in copyPhysReg.
13*9880d681SAndroid Build Coastguard Worker;
14*9880d681SAndroid Build Coastguard Worker; <rdar://problem/10248099>
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Workerdefine void @f() nounwind uwtable ssp {
17*9880d681SAndroid Build Coastguard Workerentry:
18*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* undef, align 4
19*9880d681SAndroid Build Coastguard Worker  %add = add i32 0, %0
20*9880d681SAndroid Build Coastguard Worker  %conv1 = trunc i32 %add to i16
21*9880d681SAndroid Build Coastguard Worker  %bf.value = and i16 %conv1, 255
22*9880d681SAndroid Build Coastguard Worker  %1 = and i16 %bf.value, 255
23*9880d681SAndroid Build Coastguard Worker  %2 = shl i16 %1, 8
24*9880d681SAndroid Build Coastguard Worker  %3 = load i16, i16* undef, align 1
25*9880d681SAndroid Build Coastguard Worker  %4 = and i16 %3, 255
26*9880d681SAndroid Build Coastguard Worker  %5 = or i16 %4, %2
27*9880d681SAndroid Build Coastguard Worker  store i16 %5, i16* undef, align 1
28*9880d681SAndroid Build Coastguard Worker  %6 = load i16, i16* undef, align 1
29*9880d681SAndroid Build Coastguard Worker  %7 = lshr i16 %6, 8
30*9880d681SAndroid Build Coastguard Worker  %bf.clear2 = and i16 %7, 255
31*9880d681SAndroid Build Coastguard Worker  %conv3 = zext i16 %bf.clear2 to i32
32*9880d681SAndroid Build Coastguard Worker  %rem = srem i32 %conv3, 15
33*9880d681SAndroid Build Coastguard Worker  %conv4 = trunc i32 %rem to i16
34*9880d681SAndroid Build Coastguard Worker  %bf.value5 = and i16 %conv4, 255
35*9880d681SAndroid Build Coastguard Worker  %8 = and i16 %bf.value5, 255
36*9880d681SAndroid Build Coastguard Worker  %9 = shl i16 %8, 8
37*9880d681SAndroid Build Coastguard Worker  %10 = or i16 undef, %9
38*9880d681SAndroid Build Coastguard Worker  store i16 %10, i16* undef, align 1
39*9880d681SAndroid Build Coastguard Worker  ret void
40*9880d681SAndroid Build Coastguard Worker}
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Worker; This test case extracts a sub_8bit_hi sub-register:
43*9880d681SAndroid Build Coastguard Worker;
44*9880d681SAndroid Build Coastguard Worker;       %vreg2<def> = COPY %vreg1:sub_8bit_hi; GR8:%vreg2 GR64_ABCD:%vreg1
45*9880d681SAndroid Build Coastguard Worker;       TEST8ri %vreg2, 1, %EFLAGS<imp-def>; GR8:%vreg2
46*9880d681SAndroid Build Coastguard Worker;
47*9880d681SAndroid Build Coastguard Worker; %vreg2 must be constrained to GR8_NOREX, or the COPY could become impossible.
48*9880d681SAndroid Build Coastguard Worker;
49*9880d681SAndroid Build Coastguard Worker; PR11088
50*9880d681SAndroid Build Coastguard Worker
51*9880d681SAndroid Build Coastguard Workerdefine fastcc i32 @g(i64 %FB) nounwind uwtable readnone align 2 {
52*9880d681SAndroid Build Coastguard Workerentry:
53*9880d681SAndroid Build Coastguard Worker  %and32 = and i64 %FB, 256
54*9880d681SAndroid Build Coastguard Worker  %cmp33 = icmp eq i64 %and32, 0
55*9880d681SAndroid Build Coastguard Worker  %Features.6.or35 = select i1 %cmp33, i32 0, i32 undef
56*9880d681SAndroid Build Coastguard Worker  %cmp38 = icmp eq i64 undef, 0
57*9880d681SAndroid Build Coastguard Worker  %or40 = or i32 %Features.6.or35, 4
58*9880d681SAndroid Build Coastguard Worker  %Features.8 = select i1 %cmp38, i32 %Features.6.or35, i32 %or40
59*9880d681SAndroid Build Coastguard Worker  %and42 = and i64 %FB, 32
60*9880d681SAndroid Build Coastguard Worker  %or45 = or i32 %Features.8, 2
61*9880d681SAndroid Build Coastguard Worker  %cmp43 = icmp eq i64 %and42, 0
62*9880d681SAndroid Build Coastguard Worker  %Features.8.or45 = select i1 %cmp43, i32 %Features.8, i32 %or45
63*9880d681SAndroid Build Coastguard Worker  %and47 = and i64 %FB, 8192
64*9880d681SAndroid Build Coastguard Worker  %cmp48 = icmp eq i64 %and47, 0
65*9880d681SAndroid Build Coastguard Worker  %or50 = or i32 %Features.8.or45, 32
66*9880d681SAndroid Build Coastguard Worker  %Features.10 = select i1 %cmp48, i32 %Features.8.or45, i32 %or50
67*9880d681SAndroid Build Coastguard Worker  %or55 = or i32 %Features.10, 64
68*9880d681SAndroid Build Coastguard Worker  %Features.10.or55 = select i1 undef, i32 %Features.10, i32 %or55
69*9880d681SAndroid Build Coastguard Worker  %and57 = lshr i64 %FB, 2
70*9880d681SAndroid Build Coastguard Worker  %and57.tr = trunc i64 %and57 to i32
71*9880d681SAndroid Build Coastguard Worker  %or60 = and i32 %and57.tr, 1
72*9880d681SAndroid Build Coastguard Worker  %Features.12 = or i32 %Features.10.or55, %or60
73*9880d681SAndroid Build Coastguard Worker  %and62 = and i64 %FB, 128
74*9880d681SAndroid Build Coastguard Worker  %or65 = or i32 %Features.12, 8
75*9880d681SAndroid Build Coastguard Worker  %cmp63 = icmp eq i64 %and62, 0
76*9880d681SAndroid Build Coastguard Worker  %Features.12.or65 = select i1 %cmp63, i32 %Features.12, i32 %or65
77*9880d681SAndroid Build Coastguard Worker  %Features.14 = select i1 undef, i32 undef, i32 %Features.12.or65
78*9880d681SAndroid Build Coastguard Worker  %Features.16 = select i1 undef, i32 undef, i32 %Features.14
79*9880d681SAndroid Build Coastguard Worker  ret i32 %Features.16
80*9880d681SAndroid Build Coastguard Worker}
81