Skip to content

Commit 40486d7

Browse files
author
Dan Gohman
committed
[WebAssembly] Call signExtend to get sign extended register
Patch by Jatin Bhateja! Differential Revision: https://reviews.llvm.org/D39529 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317710 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 29ba7f6 commit 40486d7

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/Target/WebAssembly/WebAssemblyFastISel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ unsigned WebAssemblyFastISel::getRegForUnsignedValue(const Value *V) {
541541
unsigned WebAssemblyFastISel::getRegForSignedValue(const Value *V) {
542542
MVT::SimpleValueType From = getSimpleType(V->getType());
543543
MVT::SimpleValueType To = getLegalType(From);
544-
return zeroExtend(getRegForValue(V), V, From, To);
544+
return signExtend(getRegForValue(V), V, From, To);
545545
}
546546

547547
unsigned WebAssemblyFastISel::getRegForPromotedValue(const Value *V,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -march=wasm32 | FileCheck %s
3+
4+
declare i32 @get_int(i16 %arg)
5+
6+
define i32 @func_1(i16 %arg1 , i32 %arg2) #0 {
7+
; CHECK-LABEL: func_1:
8+
; CHECK: # BB#0: # %entry
9+
; CHECK-NEXT: i32.const $push1=, 16
10+
; CHECK-NEXT: i32.shl $push2=, $0, $pop1
11+
; CHECK-NEXT: i32.const $push4=, 16
12+
; CHECK-NEXT: i32.shr_s $push3=, $pop2, $pop4
13+
; CHECK-NEXT: i32.call $push0=, get_int@FUNCTION, $pop3
14+
; CHECK-NEXT: # fallthrough-return: $pop0
15+
; CHECK-NEXT: .endfunc
16+
entry:
17+
%retval = call i32 @get_int(i16 signext %arg1)
18+
ret i32 %retval
19+
}
20+
21+
attributes #0 = {noinline nounwind optnone}
22+

0 commit comments

Comments
 (0)