1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s
--- |
declare void @foo()
define void @self() { ret void }
define void @self_with_copy() { ret void }
define void @self_not_equivalent_overwrite_w0() { ret void }
define void @self_not_equivalent_overwrite_w0_implicit() { ret void }
define void @self_not_equivalent_different_copies() { ret void }
define void @self_with_assert_zext() { ret void }
...
---
name: self
tracksRegLiveness: true
body: |
bb.0:
liveins: $w0, $w1
; Optimize (cond ? %a : %a) -> %a
; CHECK-LABEL: name: self
; CHECK: liveins: $w0, $w1
; CHECK: %a:_(s32) = COPY $w0
; CHECK: $w0 = COPY %a(s32)
; CHECK: RET_ReallyLR implicit $w0
%a:_(s32) = COPY $w0
%cond_wide:gpr(s32) = COPY $w1
%cond:gpr(s1) = G_TRUNC %cond_wide(s32)
%select:_(s32) = G_SELECT %cond(s1), %a, %a
$w0 = COPY %select(s32)
RET_ReallyLR implicit $w0
...
---
name: self_with_copy
tracksRegLiveness: true
body: |
bb.0:
liveins: $w0, $w1
; Optimize (cond ? %a : %b) -> %a
;
; This shows that we are looking through copies correctly and deduce that
; %b is a copy from %a.
;
; CHECK-LABEL: name: self_with_copy
; CHECK: liveins: $w0, $w1
; CHECK: %a:_(s32) = COPY $w0
; CHECK: $w0 = COPY %a(s32)
; CHECK: RET_ReallyLR implicit $w0
%a:_(s32) = COPY $w0
%b:_(s32) = COPY %a
%cond_wide:gpr(s32) = COPY $w1
%cond:gpr(s1) = G_TRUNC %cond_wide(s32)
%select:_(s32) = G_SELECT %cond(s1), %a, %b
$w0 = COPY %select(s32)
RET_ReallyLR implicit $w0
...
---
name: self_not_equivalent_overwrite_w0
tracksRegLiveness: true
body: |
bb.0:
liveins: $w0, $w1
;
; $w0 is overwritten by a copy from $w1, so the copies for %a and %b are
; not the same.
;
; CHECK-LABEL: name: self_not_equivalent_overwrite_w0
; CHECK: liveins: $w0, $w1
; CHECK: %a:_(s32) = COPY $w0
; CHECK: $w0 = COPY $w1
; CHECK: %b:_(s32) = COPY $w0
; CHECK: %cond_wide:gpr(s32) = COPY $w1
; CHECK: %cond:gpr(s1) = G_TRUNC %cond_wide(s32)
; CHECK: %select:_(s32) = G_SELECT %cond(s1), %a, %b
; CHECK: $w0 = COPY %select(s32)
; CHECK: RET_ReallyLR implicit $w0
%a:_(s32) = COPY $w0
$w0 = COPY $w1
%b:_(s32) = COPY $w0
%cond_wide:gpr(s32) = COPY $w1
%cond:gpr(s1) = G_TRUNC %cond_wide(s32)
%select:_(s32) = G_SELECT %cond(s1), %a, %b
$w0 = COPY %select(s32)
RET_ReallyLR implicit $w0
...
---
name: self_not_equivalent_overwrite_w0_implicit
tracksRegLiveness: true
body: |
bb.0:
liveins: $w0, $w1
;
; $w0 is overwritten by a call which defines it implicitly, so the copies
; are not the same.
;
; CHECK-LABEL: name: self_not_equivalent_overwrite_w0_implicit
; CHECK: liveins: $w0, $w1
; CHECK: %a:_(s32) = COPY $w0
; CHECK: BL @foo, implicit-def $w0
; CHECK: %b:_(s32) = COPY $w0
; CHECK: %cond_wide:gpr(s32) = COPY $w1
; CHECK: %cond:gpr(s1) = G_TRUNC %cond_wide(s32)
; CHECK: %select:_(s32) = G_SELECT %cond(s1), %a, %b
; CHECK: $w0 = COPY %select(s32)
; CHECK: RET_ReallyLR implicit $w0
%a:_(s32) = COPY $w0
BL @foo, implicit-def $w0
%b:_(s32) = COPY $w0
%cond_wide:gpr(s32) = COPY $w1
%cond:gpr(s1) = G_TRUNC %cond_wide(s32)
%select:_(s32) = G_SELECT %cond(s1), %a, %b
$w0 = COPY %select(s32)
RET_ReallyLR implicit $w0
...
---
name: self_not_equivalent_different_copies
tracksRegLiveness: true
body: |
bb.0:
liveins: $w0, $w1
; In this case, the copies are not equivalent, so there is no optimization.
;
; CHECK-LABEL: name: self_not_equivalent_different_copies
; CHECK: liveins: $w0, $w1
; CHECK: %a:_(s32) = COPY $w0
; CHECK: %b:_(s32) = COPY $w1
; CHECK: %cond_wide:gpr(s32) = COPY $w1
; CHECK: %cond:gpr(s1) = G_TRUNC %cond_wide(s32)
; CHECK: %select:_(s32) = G_SELECT %cond(s1), %a, %b
; CHECK: $w0 = COPY %select(s32)
; CHECK: RET_ReallyLR implicit $w0
%a:_(s32) = COPY $w0
%b:_(s32) = COPY $w1
%c:_(s32) = COPY %b
%cond_wide:gpr(s32) = COPY $w1
%cond:gpr(s1) = G_TRUNC %cond_wide(s32)
%select:_(s32) = G_SELECT %cond(s1), %a, %c
$w0 = COPY %select(s32)
RET_ReallyLR implicit $w0
...
---
name: self_with_assert_zext
tracksRegLiveness: true
body: |
bb.0:
liveins: $w0, $w1
; We should walk through G_ASSERT_ZEXT as if it's a copy, and remove the
; G_SELECT.
;
; CHECK-LABEL: name: self_with_assert_zext
; CHECK: liveins: $w0, $w1
; CHECK: %a:_(s32) = COPY $w0
; CHECK: %a_assert_zext:_(s32) = G_ASSERT_ZEXT %a, 16
; CHECK: $w0 = COPY %a_assert_zext(s32)
; CHECK: RET_ReallyLR implicit $w0
%a:_(s32) = COPY $w0
%a_assert_zext:_(s32) = G_ASSERT_ZEXT %a, 16
%b:_(s32) = COPY %a_assert_zext
%cond_wide:gpr(s32) = COPY $w1
%cond:gpr(s1) = G_TRUNC %cond_wide(s32)
%select:_(s32) = G_SELECT %cond(s1), %a_assert_zext, %b
$w0 = COPY %select(s32)
RET_ReallyLR implicit $w0
|