xref: /llvm-project/llvm/test/CodeGen/X86/inline-asm-memop.ll (revision 46505b3cbfc5f48f28431b9141085c5d71ddf1c4)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
3
4; A bug in X86DAGToDAGISel::matchAddressRecursively create a zext SDValue which
5; is quickly replaced by other SDValue but already pushed into vector for later
6; calling for SelectionDAGISel::Select_INLINEASM getNode builder, see issue
7; 82431 for more infomation.
8
9define i64 @PR82431_0(i8 %call, ptr %b) {
10; CHECK-LABEL: PR82431_0:
11; CHECK:       # %bb.0: # %entry
12; CHECK-NEXT:    movzbl %dil, %eax
13; CHECK-NEXT:    movq 8(%rsi,%rax,8), %rax
14; CHECK-NEXT:    retq
15entry:
16  %narrow = add nuw i8 %call, 1
17  %idxprom = zext i8 %narrow to i64
18  %arrayidx = getelementptr [1 x i64], ptr %b, i64 0, i64 %idxprom
19  %ret_val = load i64, ptr %arrayidx
20  ret i64 %ret_val
21}
22
23define i32 @PR82431_1(i32 %0, ptr %f) {
24; CHECK-LABEL: PR82431_1:
25; CHECK:       # %bb.0: # %entry
26; CHECK-NEXT:    # kill: def $edi killed $edi def $rdi
27; CHECK-NEXT:    addl %edi, %edi
28; CHECK-NEXT:    andl $8, %edi
29; CHECK-NEXT:    movl 4(%rsi,%rdi), %eax
30; CHECK-NEXT:    retq
31entry:
32  %shr = lshr i32 %0, 1
33  %and = and i32 %shr, 2
34  %add = or i32 %and, 1
35  %idxprom = zext i32 %add to i64
36  %arrayidx = getelementptr [0 x i32], ptr %f, i64 0, i64 %idxprom
37  %ret_val = load i32, ptr %arrayidx
38  ret i32 %ret_val
39}
40
41define void @PR82431_2(i8 %call, ptr %b) {
42; CHECK-LABEL: PR82431_2:
43; CHECK:       # %bb.0: # %entry
44; CHECK-NEXT:    movzbl %dil, %eax
45; CHECK-NEXT:    #APP
46; CHECK-NEXT:    #NO_APP
47; CHECK-NEXT:    retq
48entry:
49  %narrow = add nuw i8 %call, 1
50  %idxprom = zext i8 %narrow to i64
51  %arrayidx = getelementptr [1 x i64], ptr %b, i64 0, i64 %idxprom
52  tail call void asm "", "=*m,*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %arrayidx, ptr elementtype(i64) %arrayidx)
53  ret void
54}
55
56define void @PR82431_3(i32 %0, ptr %f) {
57; CHECK-LABEL: PR82431_3:
58; CHECK:       # %bb.0: # %entry
59; CHECK-NEXT:    # kill: def $edi killed $edi def $rdi
60; CHECK-NEXT:    addl %edi, %edi
61; CHECK-NEXT:    andl $8, %edi
62; CHECK-NEXT:    #APP
63; CHECK-NEXT:    #NO_APP
64; CHECK-NEXT:    retq
65entry:
66  %shr = lshr i32 %0, 1
67  %and = and i32 %shr, 2
68  %add = or i32 %and, 1
69  %idxprom = zext i32 %add to i64
70  %arrayidx = getelementptr [0 x i32], ptr %f, i64 0, i64 %idxprom
71  tail call void asm "", "=*m,*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %arrayidx, ptr elementtype(i32) %arrayidx)
72  ret void
73}
74