1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc %s -o - -mtriple=x86_64-unknown-linux -run-pass=twoaddressinstruction -verify-machineinstrs | FileCheck %s
4 # In TwoAddressInstructionPass, new instructions should be added to DistanceMap.
5 # In this case, function convertInstTo3Addr is called on the first ADD
6 # instruction, extra COPY instructions are generated. If they are not added to
7 # DistanceMap, function noUseAfterLastDef computes a wrong value for the later
8 # ADD instruction, and a different commute decision is made.
12 source_filename = "t.ll"
13 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
14 target triple = "x86_64-unknown-linux"
16 declare i16 @llvm.sadd.sat.i16(i16, i16)
18 define signext i16 @func16(i16 signext %x, i16 signext %y, i16 signext %z) nounwind {
20 %tmp = call i16 @llvm.sadd.sat.i16(i16 %x, i16 %a)
28 tracksRegLiveness: true
30 - { id: 0, class: gr32 }
31 - { id: 1, class: gr32 }
32 - { id: 2, class: gr32 }
33 - { id: 3, class: gr16 }
34 - { id: 4, class: gr32 }
35 - { id: 5, class: gr16 }
36 - { id: 6, class: gr16 }
37 - { id: 7, class: gr32 }
38 - { id: 8, class: gr32 }
39 - { id: 9, class: gr32 }
40 - { id: 10, class: gr16 }
41 - { id: 11, class: gr32 }
42 - { id: 13, class: gr32 }
43 - { id: 14, class: gr16 }
48 liveins: $edi, $esi, $edx
49 ; CHECK-LABEL: name: func16
50 ; CHECK: liveins: $edi, $esi, $edx
52 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY killed $edx
53 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gr32 = COPY killed $esi
54 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gr32 = COPY killed $edi
55 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gr16 = COPY killed [[COPY2]].sub_16bit
56 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:gr32 = COPY [[COPY1]]
57 ; CHECK-NEXT: [[IMUL32rr:%[0-9]+]]:gr32 = IMUL32rr [[IMUL32rr]], killed [[COPY]], implicit-def dead $eflags
58 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:gr16 = COPY killed [[IMUL32rr]].sub_16bit
59 ; CHECK-NEXT: [[DEF:%[0-9]+]]:gr64_nosp = IMPLICIT_DEF
60 ; CHECK-NEXT: [[DEF]].sub_16bit:gr64_nosp = COPY [[COPY3]]
61 ; CHECK-NEXT: [[DEF1:%[0-9]+]]:gr64_nosp = IMPLICIT_DEF
62 ; CHECK-NEXT: [[DEF1]].sub_16bit:gr64_nosp = COPY [[COPY4]]
63 ; CHECK-NEXT: [[LEA64_32r:%[0-9]+]]:gr32 = LEA64_32r killed [[DEF]], 1, killed [[DEF1]], 0, $noreg
64 ; CHECK-NEXT: [[COPY5:%[0-9]+]]:gr16 = COPY killed [[LEA64_32r]].sub_16bit
65 ; CHECK-NEXT: [[MOVSX32rr16_:%[0-9]+]]:gr32 = MOVSX32rr16 killed [[COPY5]]
66 ; CHECK-NEXT: [[COPY6:%[0-9]+]]:gr32 = COPY [[MOVSX32rr16_]]
67 ; CHECK-NEXT: [[SAR32ri:%[0-9]+]]:gr32 = SAR32ri [[SAR32ri]], 15, implicit-def dead $eflags
68 ; CHECK-NEXT: [[COPY6:%[0-9]+]]:gr32 = COPY [[SAR32ri]]
69 ; CHECK-NEXT: [[XOR32ri:%[0-9]+]]:gr32 = XOR32ri [[XOR32ri]], -32768, implicit-def dead $eflags
70 ; CHECK-NEXT: [[COPY6:%[0-9]+]]:gr16 = COPY [[COPY3]]
71 ; CHECK-NEXT: [[ADD16rr:%[0-9]+]]:gr16 = ADD16rr [[ADD16rr]], killed [[COPY4]], implicit-def $eflags
72 ; CHECK-NEXT: undef %11.sub_16bit:gr32 = COPY killed [[ADD16rr]]
73 ; CHECK-NEXT: [[COPY6:%[0-9]+]]:gr32 = COPY [[XOR32ri]]
74 ; CHECK-NEXT: [[CMOV32rr:%[0-9]+]]:gr32 = CMOV32rr [[CMOV32rr]], killed %11, 1, implicit killed $eflags
75 ; CHECK-NEXT: [[COPY6:%[0-9]+]]:gr16 = COPY killed [[CMOV32rr]].sub_16bit
76 ; CHECK-NEXT: $ax = COPY killed [[COPY6]]
77 ; CHECK-NEXT: RET 0, killed $ax
78 %2:gr32 = COPY killed $edx
79 %1:gr32 = COPY killed $esi
80 %0:gr32 = COPY killed $edi
81 %3:gr16 = COPY killed %0.sub_16bit:gr32
82 %4:gr32 = IMUL32rr killed %1:gr32, killed %2:gr32, implicit-def dead $eflags
83 %5:gr16 = COPY killed %4.sub_16bit:gr32
84 %6:gr16 = ADD16rr %3:gr16, %5:gr16, implicit-def dead $eflags
85 %7:gr32 = MOVSX32rr16 killed %6:gr16
86 %8:gr32 = SAR32ri killed %7:gr32, 15, implicit-def dead $eflags
87 %9:gr32 = XOR32ri killed %8:gr32, -32768, implicit-def dead $eflags
88 %10:gr16 = ADD16rr killed %3:gr16, killed %5:gr16, implicit-def $eflags
89 %11:gr32 = INSERT_SUBREG undef %12:gr32, killed %10:gr16, %subreg.sub_16bit
90 %13:gr32 = CMOV32rr killed %11:gr32, killed %9:gr32, 0, implicit killed $eflags
91 %14:gr16 = COPY killed %13.sub_16bit:gr32
92 $ax = COPY killed %14:gr16