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
|
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple aarch64-apple-ios -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=DARWIN
# RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=UNKNOWN
#
# Check that on Darwin we can combine to G_BZERO. Without Darwin, this should
# stay as memset.
--- |
define void @bzero_unknown_width() { unreachable }
define void @bzero_tail_unknown_width() { unreachable }
define void @bzero_constant_width() { unreachable }
define void @bzero_constant_width_minsize() minsize { unreachable }
define void @not_zero() minsize { unreachable }
...
---
name: bzero_unknown_width
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0, $x1
; Always use G_BZERO when the memset width is unknown on Darwin.
; DARWIN-LABEL: name: bzero_unknown_width
; DARWIN: liveins: $x0, $x1
; DARWIN: %ptr:_(p0) = COPY $x0
; DARWIN: %width:_(s64) = COPY $x1
; DARWIN: G_BZERO %ptr(p0), %width(s64), 0 :: (store (s32))
; DARWIN: RET_ReallyLR
; UNKNOWN-LABEL: name: bzero_unknown_width
; UNKNOWN: liveins: $x0, $x1
; UNKNOWN: %ptr:_(p0) = COPY $x0
; UNKNOWN: %zero:_(s8) = G_CONSTANT i8 0
; UNKNOWN: %width:_(s64) = COPY $x1
; UNKNOWN: G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
; UNKNOWN: RET_ReallyLR
%ptr:_(p0) = COPY $x0
%zero:_(s8) = G_CONSTANT i8 0
%width:_(s64) = COPY $x1
G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
RET_ReallyLR
...
---
name: bzero_tail_unknown_width
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0, $x1
; DARWIN-LABEL: name: bzero_tail_unknown_width
; DARWIN: liveins: $x0, $x1
; DARWIN: %ptr:_(p0) = COPY $x0
; DARWIN: %width:_(s64) = COPY $x1
; DARWIN: G_BZERO %ptr(p0), %width(s64), 1 :: (store (s32))
; DARWIN: RET_ReallyLR
; UNKNOWN-LABEL: name: bzero_tail_unknown_width
; UNKNOWN: liveins: $x0, $x1
; UNKNOWN: %ptr:_(p0) = COPY $x0
; UNKNOWN: %zero:_(s8) = G_CONSTANT i8 0
; UNKNOWN: %width:_(s64) = COPY $x1
; UNKNOWN: G_MEMSET %ptr(p0), %zero(s8), %width(s64), 1 :: (store (s32))
; UNKNOWN: RET_ReallyLR
%ptr:_(p0) = COPY $x0
%zero:_(s8) = G_CONSTANT i8 0
%width:_(s64) = COPY $x1
G_MEMSET %ptr(p0), %zero(s8), %width(s64), 1 :: (store (s32))
RET_ReallyLR
...
---
name: bzero_constant_width
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0, $x1
; For values >256, we should use G_BZERO on Darwin.
; DARWIN-LABEL: name: bzero_constant_width
; DARWIN: liveins: $x0, $x1
; DARWIN: %ptr:_(p0) = COPY $x0
; DARWIN: %width:_(s64) = G_CONSTANT i64 1024
; DARWIN: G_BZERO %ptr(p0), %width(s64), 0 :: (store (s32))
; DARWIN: RET_ReallyLR
; UNKNOWN-LABEL: name: bzero_constant_width
; UNKNOWN: liveins: $x0, $x1
; UNKNOWN: %ptr:_(p0) = COPY $x0
; UNKNOWN: %zero:_(s8) = G_CONSTANT i8 0
; UNKNOWN: %width:_(s64) = G_CONSTANT i64 1024
; UNKNOWN: G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
; UNKNOWN: RET_ReallyLR
%ptr:_(p0) = COPY $x0
%zero:_(s8) = G_CONSTANT i8 0
%width:_(s64) = G_CONSTANT i64 1024
G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
RET_ReallyLR
...
---
name: bzero_constant_width_minsize
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0, $x1
; With minsize, we should always use G_BZERO to avoid a copy from wzr.
; DARWIN-LABEL: name: bzero_constant_width_minsize
; DARWIN: liveins: $x0, $x1
; DARWIN: %ptr:_(p0) = COPY $x0
; DARWIN: %width:_(s64) = G_CONSTANT i64 256
; DARWIN: G_BZERO %ptr(p0), %width(s64), 0 :: (store (s32))
; DARWIN: RET_ReallyLR
; UNKNOWN-LABEL: name: bzero_constant_width_minsize
; UNKNOWN: liveins: $x0, $x1
; UNKNOWN: %ptr:_(p0) = COPY $x0
; UNKNOWN: %zero:_(s8) = G_CONSTANT i8 0
; UNKNOWN: %width:_(s64) = G_CONSTANT i64 256
; UNKNOWN: G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
; UNKNOWN: RET_ReallyLR
%ptr:_(p0) = COPY $x0
%zero:_(s8) = G_CONSTANT i8 0
%width:_(s64) = G_CONSTANT i64 256
G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
RET_ReallyLR
...
---
name: not_zero
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0, $x1
; When the value isn't 0, don't create G_BZERO.
; DARWIN-LABEL: name: not_zero
; DARWIN: liveins: $x0, $x1
; DARWIN: %ptr:_(p0) = COPY $x0
; DARWIN: %not_zero:_(s8) = G_CONSTANT i8 1
; DARWIN: %width:_(s64) = G_CONSTANT i64 256
; DARWIN: G_MEMSET %ptr(p0), %not_zero(s8), %width(s64), 0 :: (store (s32))
; DARWIN: RET_ReallyLR
; UNKNOWN-LABEL: name: not_zero
; UNKNOWN: liveins: $x0, $x1
; UNKNOWN: %ptr:_(p0) = COPY $x0
; UNKNOWN: %not_zero:_(s8) = G_CONSTANT i8 1
; UNKNOWN: %width:_(s64) = G_CONSTANT i64 256
; UNKNOWN: G_MEMSET %ptr(p0), %not_zero(s8), %width(s64), 0 :: (store (s32))
; UNKNOWN: RET_ReallyLR
%ptr:_(p0) = COPY $x0
%not_zero:_(s8) = G_CONSTANT i8 1
%width:_(s64) = G_CONSTANT i64 256
G_MEMSET %ptr(p0), %not_zero(s8), %width(s64), 0 :: (store (s32))
RET_ReallyLR
|