| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6 |
| ; RUN: llc < %s -O0 --global-isel -mattr=-sign-ext -disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck %s -check-prefixes=CHECK,NO-SIGNEXT |
| ; RUN: llc < %s -O0 --global-isel -mattr=+sign-ext -disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck %s -check-prefixes=CHECK,SIGNEXT |
| |
| target triple = "wasm32-unknown-unknown" |
| |
| define i8 @ashr_i8(i8 %x) { |
| ; NO-SIGNEXT-LABEL: ashr_i8: |
| ; NO-SIGNEXT: .functype ashr_i8 (i32) -> (i32) |
| ; NO-SIGNEXT-NEXT: .local i32, i32 |
| ; NO-SIGNEXT-NEXT: # %bb.0: |
| ; NO-SIGNEXT-NEXT: i32.const $push3=, 5 |
| ; NO-SIGNEXT-NEXT: local.set 1, $pop3 |
| ; NO-SIGNEXT-NEXT: i32.const $push4=, 24 |
| ; NO-SIGNEXT-NEXT: local.set 2, $pop4 |
| ; NO-SIGNEXT-NEXT: local.get $push6=, 0 |
| ; NO-SIGNEXT-NEXT: local.get $push5=, 2 |
| ; NO-SIGNEXT-NEXT: i32.shl $push2=, $pop6, $pop5 |
| ; NO-SIGNEXT-NEXT: local.get $push7=, 2 |
| ; NO-SIGNEXT-NEXT: i32.shr_s $push0=, $pop2, $pop7 |
| ; NO-SIGNEXT-NEXT: local.get $push8=, 1 |
| ; NO-SIGNEXT-NEXT: i32.shr_s $push1=, $pop0, $pop8 |
| ; NO-SIGNEXT-NEXT: return $pop1 |
| ; |
| ; SIGNEXT-LABEL: ashr_i8: |
| ; SIGNEXT: .functype ashr_i8 (i32) -> (i32) |
| ; SIGNEXT-NEXT: .local i32 |
| ; SIGNEXT-NEXT: # %bb.0: |
| ; SIGNEXT-NEXT: i32.const $push2=, 5 |
| ; SIGNEXT-NEXT: local.set 1, $pop2 |
| ; SIGNEXT-NEXT: local.get $push3=, 0 |
| ; SIGNEXT-NEXT: i32.extend8_s $push0=, $pop3 |
| ; SIGNEXT-NEXT: local.get $push4=, 1 |
| ; SIGNEXT-NEXT: i32.shr_s $push1=, $pop0, $pop4 |
| ; SIGNEXT-NEXT: return $pop1 |
| %a = ashr i8 %x, 5 |
| ret i8 %a |
| } |
| |
| define i8 @ashrv_i8(i8 %x, i8 %y) { |
| ; NO-SIGNEXT-LABEL: ashrv_i8: |
| ; NO-SIGNEXT: .functype ashrv_i8 (i32, i32) -> (i32) |
| ; NO-SIGNEXT-NEXT: .local i32 |
| ; NO-SIGNEXT-NEXT: # %bb.0: |
| ; NO-SIGNEXT-NEXT: i32.const $push5=, 24 |
| ; NO-SIGNEXT-NEXT: local.set 2, $pop5 |
| ; NO-SIGNEXT-NEXT: local.get $push7=, 0 |
| ; NO-SIGNEXT-NEXT: local.get $push6=, 2 |
| ; NO-SIGNEXT-NEXT: i32.shl $push4=, $pop7, $pop6 |
| ; NO-SIGNEXT-NEXT: local.get $push8=, 2 |
| ; NO-SIGNEXT-NEXT: i32.shr_s $push0=, $pop4, $pop8 |
| ; NO-SIGNEXT-NEXT: local.get $push9=, 1 |
| ; NO-SIGNEXT-NEXT: i32.const $push3=, 255 |
| ; NO-SIGNEXT-NEXT: i32.and $push2=, $pop9, $pop3 |
| ; NO-SIGNEXT-NEXT: i32.shr_s $push1=, $pop0, $pop2 |
| ; NO-SIGNEXT-NEXT: return $pop1 |
| ; |
| ; SIGNEXT-LABEL: ashrv_i8: |
| ; SIGNEXT: .functype ashrv_i8 (i32, i32) -> (i32) |
| ; SIGNEXT-NEXT: # %bb.0: |
| ; SIGNEXT-NEXT: local.get $push4=, 0 |
| ; SIGNEXT-NEXT: i32.extend8_s $push0=, $pop4 |
| ; SIGNEXT-NEXT: local.get $push5=, 1 |
| ; SIGNEXT-NEXT: i32.const $push3=, 255 |
| ; SIGNEXT-NEXT: i32.and $push2=, $pop5, $pop3 |
| ; SIGNEXT-NEXT: i32.shr_s $push1=, $pop0, $pop2 |
| ; SIGNEXT-NEXT: return $pop1 |
| %a = ashr i8 %x, %y |
| ret i8 %a |
| } |
| |
| define i16 @ashr_i16(i16 %x) { |
| ; NO-SIGNEXT-LABEL: ashr_i16: |
| ; NO-SIGNEXT: .functype ashr_i16 (i32) -> (i32) |
| ; NO-SIGNEXT-NEXT: .local i32, i32 |
| ; NO-SIGNEXT-NEXT: # %bb.0: |
| ; NO-SIGNEXT-NEXT: i32.const $push3=, 13 |
| ; NO-SIGNEXT-NEXT: local.set 1, $pop3 |
| ; NO-SIGNEXT-NEXT: i32.const $push4=, 16 |
| ; NO-SIGNEXT-NEXT: local.set 2, $pop4 |
| ; NO-SIGNEXT-NEXT: local.get $push6=, 0 |
| ; NO-SIGNEXT-NEXT: local.get $push5=, 2 |
| ; NO-SIGNEXT-NEXT: i32.shl $push2=, $pop6, $pop5 |
| ; NO-SIGNEXT-NEXT: local.get $push7=, 2 |
| ; NO-SIGNEXT-NEXT: i32.shr_s $push0=, $pop2, $pop7 |
| ; NO-SIGNEXT-NEXT: local.get $push8=, 1 |
| ; NO-SIGNEXT-NEXT: i32.shr_s $push1=, $pop0, $pop8 |
| ; NO-SIGNEXT-NEXT: return $pop1 |
| ; |
| ; SIGNEXT-LABEL: ashr_i16: |
| ; SIGNEXT: .functype ashr_i16 (i32) -> (i32) |
| ; SIGNEXT-NEXT: .local i32 |
| ; SIGNEXT-NEXT: # %bb.0: |
| ; SIGNEXT-NEXT: i32.const $push2=, 13 |
| ; SIGNEXT-NEXT: local.set 1, $pop2 |
| ; SIGNEXT-NEXT: local.get $push3=, 0 |
| ; SIGNEXT-NEXT: i32.extend16_s $push0=, $pop3 |
| ; SIGNEXT-NEXT: local.get $push4=, 1 |
| ; SIGNEXT-NEXT: i32.shr_s $push1=, $pop0, $pop4 |
| ; SIGNEXT-NEXT: return $pop1 |
| %a = ashr i16 %x, 13 |
| ret i16 %a |
| } |
| |
| define i16 @ashrv_i16(i16 %x, i16 %y) { |
| ; NO-SIGNEXT-LABEL: ashrv_i16: |
| ; NO-SIGNEXT: .functype ashrv_i16 (i32, i32) -> (i32) |
| ; NO-SIGNEXT-NEXT: .local i32 |
| ; NO-SIGNEXT-NEXT: # %bb.0: |
| ; NO-SIGNEXT-NEXT: i32.const $push5=, 16 |
| ; NO-SIGNEXT-NEXT: local.set 2, $pop5 |
| ; NO-SIGNEXT-NEXT: local.get $push7=, 0 |
| ; NO-SIGNEXT-NEXT: local.get $push6=, 2 |
| ; NO-SIGNEXT-NEXT: i32.shl $push4=, $pop7, $pop6 |
| ; NO-SIGNEXT-NEXT: local.get $push8=, 2 |
| ; NO-SIGNEXT-NEXT: i32.shr_s $push0=, $pop4, $pop8 |
| ; NO-SIGNEXT-NEXT: local.get $push9=, 1 |
| ; NO-SIGNEXT-NEXT: i32.const $push3=, 65535 |
| ; NO-SIGNEXT-NEXT: i32.and $push2=, $pop9, $pop3 |
| ; NO-SIGNEXT-NEXT: i32.shr_s $push1=, $pop0, $pop2 |
| ; NO-SIGNEXT-NEXT: return $pop1 |
| ; |
| ; SIGNEXT-LABEL: ashrv_i16: |
| ; SIGNEXT: .functype ashrv_i16 (i32, i32) -> (i32) |
| ; SIGNEXT-NEXT: # %bb.0: |
| ; SIGNEXT-NEXT: local.get $push4=, 0 |
| ; SIGNEXT-NEXT: i32.extend16_s $push0=, $pop4 |
| ; SIGNEXT-NEXT: local.get $push5=, 1 |
| ; SIGNEXT-NEXT: i32.const $push3=, 65535 |
| ; SIGNEXT-NEXT: i32.and $push2=, $pop5, $pop3 |
| ; SIGNEXT-NEXT: i32.shr_s $push1=, $pop0, $pop2 |
| ; SIGNEXT-NEXT: return $pop1 |
| %a = ashr i16 %x, %y |
| ret i16 %a |
| } |
| |
| define i32 @ashr_i32(i32 %x) { |
| ; CHECK-LABEL: ashr_i32: |
| ; CHECK: .functype ashr_i32 (i32) -> (i32) |
| ; CHECK-NEXT: # %bb.0: |
| ; CHECK-NEXT: local.get $push2=, 0 |
| ; CHECK-NEXT: i32.const $push0=, 21 |
| ; CHECK-NEXT: i32.shr_s $push1=, $pop2, $pop0 |
| ; CHECK-NEXT: return $pop1 |
| %a = ashr i32 %x, 21 |
| ret i32 %a |
| } |
| |
| define i32 @ashrv_i32(i32 %x, i32 %y) { |
| ; CHECK-LABEL: ashrv_i32: |
| ; CHECK: .functype ashrv_i32 (i32, i32) -> (i32) |
| ; CHECK-NEXT: # %bb.0: |
| ; CHECK-NEXT: local.get $push2=, 0 |
| ; CHECK-NEXT: local.get $push1=, 1 |
| ; CHECK-NEXT: i32.shr_s $push0=, $pop2, $pop1 |
| ; CHECK-NEXT: return $pop0 |
| %a = ashr i32 %x, %y |
| ret i32 %a |
| } |
| |
| define i64 @ashr_i64(i64 %x) { |
| ; CHECK-LABEL: ashr_i64: |
| ; CHECK: .functype ashr_i64 (i64) -> (i64) |
| ; CHECK-NEXT: # %bb.0: |
| ; CHECK-NEXT: local.get $push2=, 0 |
| ; CHECK-NEXT: i64.const $push0=, 37 |
| ; CHECK-NEXT: i64.shr_s $push1=, $pop2, $pop0 |
| ; CHECK-NEXT: return $pop1 |
| %a = ashr i64 %x, 37 |
| ret i64 %a |
| } |
| |
| define i64 @ashrv_i64(i64 %x, i64 %y) { |
| ; CHECK-LABEL: ashrv_i64: |
| ; CHECK: .functype ashrv_i64 (i64, i64) -> (i64) |
| ; CHECK-NEXT: # %bb.0: |
| ; CHECK-NEXT: local.get $push2=, 0 |
| ; CHECK-NEXT: local.get $push1=, 1 |
| ; CHECK-NEXT: i64.shr_s $push0=, $pop2, $pop1 |
| ; CHECK-NEXT: return $pop0 |
| %a = ashr i64 %x, %y |
| ret i64 %a |
| } |