1c0de13b0SYingwei Zheng; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 2c0de13b0SYingwei Zheng; RUN: llc -mtriple=riscv32 -global-isel -global-isel-abort=1 -verify-machineinstrs < %s 2>&1 | FileCheck %s --check-prefixes=RV32 3c0de13b0SYingwei Zheng; RUN: llc -mtriple=riscv64 -global-isel -global-isel-abort=1 -verify-machineinstrs < %s 2>&1 | FileCheck %s --check-prefixes=RV64 4c0de13b0SYingwei Zheng 5c0de13b0SYingwei Zhengdefine i16 @test_lshr_i48(i48 %x) { 6c0de13b0SYingwei Zheng; RV32-LABEL: test_lshr_i48: 7c0de13b0SYingwei Zheng; RV32: # %bb.0: 8c0de13b0SYingwei Zheng; RV32-NEXT: srli a0, a0, 16 9c0de13b0SYingwei Zheng; RV32-NEXT: ret 10c0de13b0SYingwei Zheng; 11c0de13b0SYingwei Zheng; RV64-LABEL: test_lshr_i48: 12c0de13b0SYingwei Zheng; RV64: # %bb.0: 13c0de13b0SYingwei Zheng; RV64-NEXT: srliw a0, a0, 16 14c0de13b0SYingwei Zheng; RV64-NEXT: ret 15c0de13b0SYingwei Zheng %lshr = lshr i48 %x, 16 16c0de13b0SYingwei Zheng %trunc = trunc i48 %lshr to i16 17c0de13b0SYingwei Zheng ret i16 %trunc 18c0de13b0SYingwei Zheng} 19c0de13b0SYingwei Zheng 20c0de13b0SYingwei Zhengdefine i16 @test_ashr_i48(i48 %x) { 21c0de13b0SYingwei Zheng; RV32-LABEL: test_ashr_i48: 22c0de13b0SYingwei Zheng; RV32: # %bb.0: 23c0de13b0SYingwei Zheng; RV32-NEXT: srai a0, a0, 16 24c0de13b0SYingwei Zheng; RV32-NEXT: ret 25c0de13b0SYingwei Zheng; 26c0de13b0SYingwei Zheng; RV64-LABEL: test_ashr_i48: 27c0de13b0SYingwei Zheng; RV64: # %bb.0: 28c0de13b0SYingwei Zheng; RV64-NEXT: sraiw a0, a0, 16 29c0de13b0SYingwei Zheng; RV64-NEXT: ret 30c0de13b0SYingwei Zheng %ashr = ashr i48 %x, 16 31c0de13b0SYingwei Zheng %trunc = trunc i48 %ashr to i16 32c0de13b0SYingwei Zheng ret i16 %trunc 33c0de13b0SYingwei Zheng} 34c0de13b0SYingwei Zheng 35c0de13b0SYingwei Zhengdefine i16 @test_shl_i48(i48 %x) { 36c0de13b0SYingwei Zheng; RV32-LABEL: test_shl_i48: 37c0de13b0SYingwei Zheng; RV32: # %bb.0: 38c0de13b0SYingwei Zheng; RV32-NEXT: slli a0, a0, 8 39c0de13b0SYingwei Zheng; RV32-NEXT: ret 40c0de13b0SYingwei Zheng; 41c0de13b0SYingwei Zheng; RV64-LABEL: test_shl_i48: 42c0de13b0SYingwei Zheng; RV64: # %bb.0: 43*d1e17a3fSCraig Topper; RV64-NEXT: slli a0, a0, 8 44c0de13b0SYingwei Zheng; RV64-NEXT: ret 45c0de13b0SYingwei Zheng %shl = shl i48 %x, 8 46c0de13b0SYingwei Zheng %trunc = trunc i48 %shl to i16 47c0de13b0SYingwei Zheng ret i16 %trunc 48c0de13b0SYingwei Zheng} 49916c8302SCraig Topper 50*d1e17a3fSCraig Topper; FIXME: Could use srlw to remove slli+srli. 51916c8302SCraig Topperdefine i16 @test_lshr_i48_2(i48 %x, i48 %y) { 52916c8302SCraig Topper; RV32-LABEL: test_lshr_i48_2: 53916c8302SCraig Topper; RV32: # %bb.0: 54916c8302SCraig Topper; RV32-NEXT: andi a2, a2, 15 55916c8302SCraig Topper; RV32-NEXT: srl a0, a0, a2 56916c8302SCraig Topper; RV32-NEXT: ret 57916c8302SCraig Topper; 58916c8302SCraig Topper; RV64-LABEL: test_lshr_i48_2: 59916c8302SCraig Topper; RV64: # %bb.0: 60916c8302SCraig Topper; RV64-NEXT: andi a1, a1, 15 61*d1e17a3fSCraig Topper; RV64-NEXT: slli a0, a0, 32 62*d1e17a3fSCraig Topper; RV64-NEXT: srli a0, a0, 32 63*d1e17a3fSCraig Topper; RV64-NEXT: srl a0, a0, a1 64916c8302SCraig Topper; RV64-NEXT: ret 65916c8302SCraig Topper %and = and i48 %y, 15 66916c8302SCraig Topper %lshr = lshr i48 %x, %and 67916c8302SCraig Topper %trunc = trunc i48 %lshr to i16 68916c8302SCraig Topper ret i16 %trunc 69916c8302SCraig Topper} 70916c8302SCraig Topper 71*d1e17a3fSCraig Topper; FIXME: Could use sraw to remove the sext.w. 72916c8302SCraig Topperdefine i16 @test_ashr_i48_2(i48 %x, i48 %y) { 73916c8302SCraig Topper; RV32-LABEL: test_ashr_i48_2: 74916c8302SCraig Topper; RV32: # %bb.0: 75916c8302SCraig Topper; RV32-NEXT: andi a2, a2, 15 76916c8302SCraig Topper; RV32-NEXT: sra a0, a0, a2 77916c8302SCraig Topper; RV32-NEXT: ret 78916c8302SCraig Topper; 79916c8302SCraig Topper; RV64-LABEL: test_ashr_i48_2: 80916c8302SCraig Topper; RV64: # %bb.0: 81916c8302SCraig Topper; RV64-NEXT: andi a1, a1, 15 82*d1e17a3fSCraig Topper; RV64-NEXT: sext.w a0, a0 83*d1e17a3fSCraig Topper; RV64-NEXT: sra a0, a0, a1 84916c8302SCraig Topper; RV64-NEXT: ret 85916c8302SCraig Topper %and = and i48 %y, 15 86916c8302SCraig Topper %ashr = ashr i48 %x, %and 87916c8302SCraig Topper %trunc = trunc i48 %ashr to i16 88916c8302SCraig Topper ret i16 %trunc 89916c8302SCraig Topper} 90916c8302SCraig Topper 91916c8302SCraig Topperdefine i16 @test_shl_i48_2(i48 %x, i48 %y) { 92916c8302SCraig Topper; RV32-LABEL: test_shl_i48_2: 93916c8302SCraig Topper; RV32: # %bb.0: 94916c8302SCraig Topper; RV32-NEXT: andi a2, a2, 15 95916c8302SCraig Topper; RV32-NEXT: sll a0, a0, a2 96916c8302SCraig Topper; RV32-NEXT: ret 97916c8302SCraig Topper; 98916c8302SCraig Topper; RV64-LABEL: test_shl_i48_2: 99916c8302SCraig Topper; RV64: # %bb.0: 100916c8302SCraig Topper; RV64-NEXT: andi a1, a1, 15 101*d1e17a3fSCraig Topper; RV64-NEXT: sll a0, a0, a1 102916c8302SCraig Topper; RV64-NEXT: ret 103916c8302SCraig Topper %and = and i48 %y, 15 104916c8302SCraig Topper %shl = shl i48 %x, %and 105916c8302SCraig Topper %trunc = trunc i48 %shl to i16 106916c8302SCraig Topper ret i16 %trunc 107916c8302SCraig Topper} 108