1 # RUN: llc -mtriple=aarch64-linux-gnu -run-pass machine-cp -o - %s | FileCheck %s 2 # Tests for MachineCopyPropagation copy forwarding. 3 --- 4 # Simple forwarding. 5 # CHECK-LABEL: name: test1 6 # CHECK: $x0 = SUBXri $x0, 1, 0 7 name: test1 8 tracksRegLiveness: true 9 body: | 10 bb.0: 11 liveins: $x0 12 renamable $x1 = COPY $x0 13 $x0 = SUBXri renamable $x1, 1, 0 14 ... 15 --- 16 # Don't forward if not renamable. 17 # CHECK-LABEL: name: test2 18 # CHECK: $x0 = SUBXri $x1, 1, 0 19 name: test2 20 tracksRegLiveness: true 21 body: | 22 bb.0: 23 liveins: $x0 24 $x1 = COPY $x0 25 $x0 = SUBXri $x1, 1, 0 26 ... 27 --- 28 # Don't forward reserved non-constant reg values. 29 # CHECK-LABEL: name: test4 30 # CHECK: $x0 = SUBXri renamable $x1, 1, 0 31 name: test4 32 tracksRegLiveness: true 33 body: | 34 bb.0: 35 liveins: $x0 36 $sp = SUBXri $sp, 16, 0 37 renamable $x1 = COPY $sp 38 $x0 = SUBXri renamable $x1, 1, 0 39 $sp = ADDXri $sp, 16, 0 40 ... 41 --- 42 # Don't violate opcode constraints when forwarding. 43 # CHECK-LABEL: name: test5 44 # CHECK: $x0 = SUBXri renamable $x1, 1, 0 45 name: test5 46 tracksRegLiveness: true 47 body: | 48 bb.0: 49 liveins: $x0 50 renamable $x1 = COPY $xzr 51 $x0 = SUBXri renamable $x1, 1, 0 52 ... 53 --- 54 # Test cross-class COPY forwarding. 55 # CHECK-LABEL: name: test6 56 # CHECK: $x2 = COPY $x0 57 name: test6 58 tracksRegLiveness: true 59 body: | 60 bb.0: 61 liveins: $x0 62 renamable $d1 = COPY $x0 63 $x2 = COPY renamable $d1 64 RET_ReallyLR implicit $x2 65 ... 66 --- 67 # Don't forward if there are overlapping implicit operands. 68 # CHECK-LABEL: name: test7 69 # CHECK: $w0 = SUBWri killed renamable $w1, 1, 0 70 name: test7 71 tracksRegLiveness: true 72 body: | 73 bb.0: 74 liveins: $w0 75 renamable $w1 = COPY $w0 76 $w0 = SUBWri killed renamable $w1, 1, 0, implicit killed $x1 77 ... 78 --- 79 # Check that kill flags are cleared. 80 # CHECK-LABEL: name: test8 81 # CHECK: $x2 = ADDXri $x0, 1, 0 82 # CHECK: $x0 = SUBXri $x0, 1, 0 83 name: test8 84 tracksRegLiveness: true 85 body: | 86 bb.0: 87 liveins: $x0 88 renamable $x1 = COPY $x0 89 $x2 = ADDXri killed $x0, 1, 0 90 $x0 = SUBXri renamable $x1, 1, 0 91 ... 92 --- 93 # Don't forward if value is clobbered. 94 # CHECK-LABEL: name: test9 95 # CHECK: $x2 = SUBXri renamable $x1, 1, 0 96 name: test9 97 tracksRegLiveness: true 98 body: | 99 bb.0: 100 liveins: $x0 101 renamable $x1 = COPY $x0 102 $x0 = ADDXri $x0, 1, 0 103 $x2 = SUBXri renamable $x1, 1, 0 104 ... 105