blob: 1fc9387fecc076d23334b82851f2d4ef6e67cf50 [file] [log] [blame]
Tim Northover27010072014-04-15 13:59:44 +00001; RUN: llc -verify-machineinstrs -o - %s -mtriple=arm64-apple-ios7.0 | FileCheck %s
Tim Northovere0e3aef2013-01-31 12:12:40 +00002
3define i64 @ror_i64(i64 %in) {
Stephen Lind24ab202013-07-14 06:24:09 +00004; CHECK-LABEL: ror_i64:
Tim Northovere0e3aef2013-01-31 12:12:40 +00005 %left = shl i64 %in, 19
6 %right = lshr i64 %in, 45
7 %val5 = or i64 %left, %right
Tim Northoveree20caa2014-05-12 18:04:06 +00008; CHECK: ror {{x[0-9]+}}, x0, #45
Tim Northovere0e3aef2013-01-31 12:12:40 +00009 ret i64 %val5
10}
11
12define i32 @ror_i32(i32 %in) {
Stephen Lind24ab202013-07-14 06:24:09 +000013; CHECK-LABEL: ror_i32:
Tim Northovere0e3aef2013-01-31 12:12:40 +000014 %left = shl i32 %in, 9
15 %right = lshr i32 %in, 23
16 %val5 = or i32 %left, %right
Tim Northoveree20caa2014-05-12 18:04:06 +000017; CHECK: ror {{w[0-9]+}}, w0, #23
Tim Northovere0e3aef2013-01-31 12:12:40 +000018 ret i32 %val5
19}
20
21define i32 @extr_i32(i32 %lhs, i32 %rhs) {
Stephen Lind24ab202013-07-14 06:24:09 +000022; CHECK-LABEL: extr_i32:
Tim Northovere0e3aef2013-01-31 12:12:40 +000023 %left = shl i32 %lhs, 6
24 %right = lshr i32 %rhs, 26
25 %val = or i32 %left, %right
26 ; Order of lhs and rhs matters here. Regalloc would have to be very odd to use
27 ; something other than w0 and w1.
28; CHECK: extr {{w[0-9]+}}, w0, w1, #26
29
30 ret i32 %val
31}
32
33define i64 @extr_i64(i64 %lhs, i64 %rhs) {
Stephen Lind24ab202013-07-14 06:24:09 +000034; CHECK-LABEL: extr_i64:
Tim Northovere0e3aef2013-01-31 12:12:40 +000035 %right = lshr i64 %rhs, 40
36 %left = shl i64 %lhs, 24
37 %val = or i64 %right, %left
38 ; Order of lhs and rhs matters here. Regalloc would have to be very odd to use
39 ; something other than w0 and w1.
40; CHECK: extr {{x[0-9]+}}, x0, x1, #40
41
42 ret i64 %val
43}
44
45; Regression test: a bad experimental pattern crept into git which optimised
46; this pattern to a single EXTR.
47define i32 @extr_regress(i32 %a, i32 %b) {
Stephen Lind24ab202013-07-14 06:24:09 +000048; CHECK-LABEL: extr_regress:
Tim Northovere0e3aef2013-01-31 12:12:40 +000049
50 %sh1 = shl i32 %a, 14
51 %sh2 = lshr i32 %b, 14
52 %val = or i32 %sh2, %sh1
53; CHECK-NOT: extr {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}, #{{[0-9]+}}
54
55 ret i32 %val
56; CHECK: ret
57}