Strahinja Petrovic | ab9573f | 2017-05-22 09:06:44 +0000 | [diff] [blame] | 1 | ; RUN: llc -O2 -march=mips64 -mcpu=mips64r2 -target-abi=n64 < %s -o - | FileCheck %s -check-prefix=MIPS64R2 |
| 2 | ; RUN: llc -O2 -march=mips -mcpu=mips32r2 < %s -o - | FileCheck %s -check-prefix=MIPS32R2 |
| 3 | ; RUN: llc -O2 -march=mips -mattr=mips16 < %s -o - | FileCheck %s -check-prefix=MIPS16 |
Strahinja Petrovic | d280ea4 | 2017-06-21 09:25:51 +0000 | [diff] [blame] | 4 | ; RUN: llc -O2 -march=mips64 -mcpu=mips64r2 -target-abi=n32 < %s -o - | FileCheck %s -check-prefix=MIPS64R2N32 |
Strahinja Petrovic | ab9573f | 2017-05-22 09:06:44 +0000 | [diff] [blame] | 5 | |
| 6 | ; #include <stdint.h> |
| 7 | ; #include <stdio.h> |
| 8 | ; struct cvmx_buf_ptr { |
| 9 | |
| 10 | ; struct { |
| 11 | ; unsigned long long addr :37; |
| 12 | ; unsigned long long addr1 :15; |
| 13 | ; unsigned int lenght:14; |
| 14 | ; uint64_t total_bytes:16; |
| 15 | ; uint64_t segs : 6; |
| 16 | ; } s; |
| 17 | ; } |
| 18 | ; |
| 19 | ; unsigned long long foo(volatile struct cvmx_buf_ptr bufptr) { |
| 20 | ; bufptr.s.addr = 123; |
| 21 | ; bufptr.s.segs = 4; |
| 22 | ; bufptr.s.lenght = 5; |
| 23 | ; bufptr.s.total_bytes = bufptr.s.lenght; |
| 24 | ; return bufptr.s.addr; |
| 25 | ; } |
| 26 | |
| 27 | ; Testing of selection INS/DINS instruction |
| 28 | |
| 29 | define i64 @f123(i64 inreg %bufptr.coerce0, i64 inreg %bufptr.coerce1) local_unnamed_addr #0 { |
| 30 | entry: |
| 31 | %bufptr.sroa.0 = alloca i64, align 8 |
| 32 | %bufptr.sroa.4 = alloca i64, align 8 |
| 33 | store i64 %bufptr.coerce0, i64* %bufptr.sroa.0, align 8 |
| 34 | store i64 %bufptr.coerce1, i64* %bufptr.sroa.4, align 8 |
| 35 | %bufptr.sroa.0.0.bufptr.sroa.0.0.bufptr.sroa.0.0.bf.load = load volatile i64, i64* %bufptr.sroa.0, align 8 |
| 36 | %bf.clear = and i64 %bufptr.sroa.0.0.bufptr.sroa.0.0.bufptr.sroa.0.0.bf.load, 134217727 |
| 37 | %bf.set = or i64 %bf.clear, 16508780544 |
| 38 | store volatile i64 %bf.set, i64* %bufptr.sroa.0, align 8 |
| 39 | %bufptr.sroa.4.0.bufptr.sroa.4.0.bufptr.sroa.4.8.bf.load2 = load volatile i64, i64* %bufptr.sroa.4, align 8 |
| 40 | %bf.clear3 = and i64 %bufptr.sroa.4.0.bufptr.sroa.4.0.bufptr.sroa.4.8.bf.load2, -16911433729 |
| 41 | %bf.set4 = or i64 %bf.clear3, 1073741824 |
| 42 | store volatile i64 %bf.set4, i64* %bufptr.sroa.4, align 8 |
| 43 | %bufptr.sroa.4.0.bufptr.sroa.4.0.bufptr.sroa.4.8.bf.load6 = load volatile i64, i64* %bufptr.sroa.4, align 8 |
| 44 | %bf.clear7 = and i64 %bufptr.sroa.4.0.bufptr.sroa.4.0.bufptr.sroa.4.8.bf.load6, 1125899906842623 |
| 45 | %bf.set8 = or i64 %bf.clear7, 5629499534213120 |
| 46 | store volatile i64 %bf.set8, i64* %bufptr.sroa.4, align 8 |
| 47 | %bufptr.sroa.4.0.bufptr.sroa.4.0.bufptr.sroa.4.8.bf.load11 = load volatile i64, i64* %bufptr.sroa.4, align 8 |
| 48 | %bf.lshr = lshr i64 %bufptr.sroa.4.0.bufptr.sroa.4.0.bufptr.sroa.4.8.bf.load11, 50 |
| 49 | %bufptr.sroa.4.0.bufptr.sroa.4.0.bufptr.sroa.4.8.bf.load13 = load volatile i64, i64* %bufptr.sroa.4, align 8 |
| 50 | %bf.shl = shl nuw nsw i64 %bf.lshr, 34 |
| 51 | %bf.clear14 = and i64 %bufptr.sroa.4.0.bufptr.sroa.4.0.bufptr.sroa.4.8.bf.load13, -1125882726973441 |
| 52 | %bf.set15 = or i64 %bf.clear14, %bf.shl |
| 53 | store volatile i64 %bf.set15, i64* %bufptr.sroa.4, align 8 |
| 54 | %bufptr.sroa.0.0.bufptr.sroa.0.0.bufptr.sroa.0.0.bf.load17 = load volatile i64, i64* %bufptr.sroa.0, align 8 |
| 55 | %bf.lshr18 = lshr i64 %bufptr.sroa.0.0.bufptr.sroa.0.0.bufptr.sroa.0.0.bf.load17, 27 |
| 56 | ret i64 %bf.lshr18 |
| 57 | } |
| 58 | |
Strahinja Petrovic | ab9573f | 2017-05-22 09:06:44 +0000 | [diff] [blame] | 59 | ; CHECK-LABEL: f123: |
Strahinja Petrovic | d280ea4 | 2017-06-21 09:25:51 +0000 | [diff] [blame] | 60 | ; MIPS64R2: daddiu $[[R0:[0-9]+]], $zero, 123 |
Strahinja Petrovic | ab9573f | 2017-05-22 09:06:44 +0000 | [diff] [blame] | 61 | ; MIPS64R2: dins $[[R0:[0-9]+]], $[[R1:[0-9]+]], 27, 37 |
Strahinja Petrovic | d280ea4 | 2017-06-21 09:25:51 +0000 | [diff] [blame] | 62 | ; MIPS64R2: daddiu $[[R0:[0-9]+]], $zero, 4 |
Strahinja Petrovic | ab9573f | 2017-05-22 09:06:44 +0000 | [diff] [blame] | 63 | ; MIPS64R2: dins $[[R0:[0-9]+]], $[[R1:[0-9]+]], 28, 6 |
Nirav Dave | d839749 | 2017-07-18 20:06:24 +0000 | [diff] [blame] | 64 | ; MIPS64R2: daddiu $[[R0:[0-9]+]], $zero, 5 |
Strahinja Petrovic | ab9573f | 2017-05-22 09:06:44 +0000 | [diff] [blame] | 65 | ; MIPS64R2: dins $[[R0:[0-9]+]], $[[R1:[0-9]+]], 50, 14 |
Strahinja Petrovic | d280ea4 | 2017-06-21 09:25:51 +0000 | [diff] [blame] | 66 | ; MIPS64R2: dsrl $[[R0:[0-9]+]], $[[R1:[0-9]+]], 50 |
Strahinja Petrovic | ab9573f | 2017-05-22 09:06:44 +0000 | [diff] [blame] | 67 | ; MIPS64R2: dins $[[R0:[0-9]+]], $[[R1:[0-9]+]], 34, 16 |
| 68 | ; MIPS32R2: ins $[[R0:[0-9]+]], $[[R1:[0-9]+]], 2, 16 |
| 69 | ; MIPS32R2-NOT: ins $[[R0:[0-9]+]], $[[R1:[0-9]+]], 18, 46 |
Strahinja Petrovic | d280ea4 | 2017-06-21 09:25:51 +0000 | [diff] [blame] | 70 | ; MIPS16-NOT: ins{{[[:space:]].*}} |
| 71 | |
| 72 | |
| 73 | ; int foo(volatile int x) { |
| 74 | ; int y = x; |
| 75 | ; y = y & -4; |
| 76 | ; x = y | 8; |
| 77 | ; return y; |
| 78 | ; } |
| 79 | |
| 80 | define i32 @foo(i32 signext %x) { |
| 81 | entry: |
| 82 | %x.addr = alloca i32, align 4 |
| 83 | store volatile i32 %x, i32* %x.addr, align 4 |
| 84 | %x.addr.0.x.addr.0. = load volatile i32, i32* %x.addr, align 4 |
| 85 | %and = and i32 %x.addr.0.x.addr.0., -4 |
| 86 | %or = or i32 %and, 8 |
| 87 | store volatile i32 %or, i32* %x.addr, align 4 |
| 88 | ret i32 %and |
| 89 | } |
| 90 | |
| 91 | ; CHECK-LABEL: foo: |
| 92 | ; MIPS64R2: ori $[[R0:[0-9]+]], $[[R0:[0-9]+]], 8 |
| 93 | ; MIPS64R2-NOT: ins {{[[:space:]].*}} |
| 94 | ; MIPS32R2: ori $[[R0:[0-9]+]], $[[R0:[0-9]+]], 8 |
| 95 | ; MIPS32R2-NOT: ins {{[[:space:]].*}} |
| 96 | ; MIPS64R2N32: ori $[[R0:[0-9]+]], $[[R0:[0-9]+]], 8 |
Nirav Dave | d839749 | 2017-07-18 20:06:24 +0000 | [diff] [blame] | 97 | ; MIPS64R2N32-NOT: ins {{[[:space:]].*}} |