diff options
author | Dan Gohman <dan433584@gmail.com> | 2016-02-22 20:04:02 +0000 |
---|---|---|
committer | Dan Gohman <dan433584@gmail.com> | 2016-02-22 20:04:02 +0000 |
commit | 3b09d279be164f3e9a16b18eced38ee75a00e6fe (patch) | |
tree | d234074f36799119b3d5d148443d5c21eb8b1c8a /llvm/test | |
parent | 56da313e866ddebe7f1188825346b0c31efd03fa (diff) | |
download | bcm5719-llvm-3b09d279be164f3e9a16b18eced38ee75a00e6fe.tar.gz bcm5719-llvm-3b09d279be164f3e9a16b18eced38ee75a00e6fe.zip |
[WebAssembly] Teach address folding to fold bitwise-or nodes.
LLVM converts adds into ors when it can prove that the operands don't share
any non-zero bits. Teach address folding to recognize or instructions with
constant operands with this property that can be folded into addresses as
if they were adds.
llvm-svn: 261562
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/CodeGen/WebAssembly/offset.ll | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/WebAssembly/offset.ll b/llvm/test/CodeGen/WebAssembly/offset.ll index 9cf04c00822..59f26f33497 100644 --- a/llvm/test/CodeGen/WebAssembly/offset.ll +++ b/llvm/test/CodeGen/WebAssembly/offset.ll @@ -125,6 +125,17 @@ define i64 @load_i64_with_unfolded_gep_offset(i64* %p) { ret i64 %t } +; CHECK-LABEL: load_i32_with_folded_or_offset: +; CHECK: i32.load8_s $push{{[0-9]+}}=, 2($pop{{[0-9]+}}){{$}} +define i32 @load_i32_with_folded_or_offset(i32 %x) { + %and = and i32 %x, -4 + %t0 = inttoptr i32 %and to i8* + %arrayidx = getelementptr inbounds i8, i8* %t0, i32 2 + %t1 = load i8, i8* %arrayidx, align 1 + %conv = sext i8 %t1 to i32 + ret i32 %conv +} + ; Same as above but with store. ; CHECK-LABEL: store_i32_with_folded_offset: @@ -245,6 +256,16 @@ define void @store_i64_with_unfolded_gep_offset(i64* %p) { ret void } +; CHECK-LABEL: store_i32_with_folded_or_offset: +; CHECK: i32.store8 $discard=, 2($pop{{[0-9]+}}), $pop{{[0-9]+}}{{$}} +define void @store_i32_with_folded_or_offset(i32 %x) { + %and = and i32 %x, -4 + %t0 = inttoptr i32 %and to i8* + %arrayidx = getelementptr inbounds i8, i8* %t0, i32 2 + store i8 0, i8* %arrayidx, align 1 + ret void +} + ; When loading from a fixed address, materialize a zero. ; CHECK-LABEL: load_i32_from_numeric_address |