diff options
| author | Leo Li <aoli@google.com> | 2017-07-10 20:45:34 +0000 |
|---|---|---|
| committer | Leo Li <aoli@google.com> | 2017-07-10 20:45:34 +0000 |
| commit | 93abd7d915fb12c9967fe2433dfc873d3b4e938d (patch) | |
| tree | c37b55fac997a6034a8646df03ff81e3e8fbcb41 /llvm/test | |
| parent | a7a77540ef747aa5674014c696a289d45a168641 (diff) | |
| download | bcm5719-llvm-93abd7d915fb12c9967fe2433dfc873d3b4e938d.tar.gz bcm5719-llvm-93abd7d915fb12c9967fe2433dfc873d3b4e938d.zip | |
[ConstantHoisting] Remove dupliate logic in constant hoisting
Summary:
As metioned in https://reviews.llvm.org/D34576, checkings in
`collectConstantCandidates` can be replaced by using
`llvm::canReplaceOperandWithVariable`.
The only special case is that `collectConstantCandidates` return false for
all `IntrinsicInst` but it is safe for us to collect constant candidates from
`IntrinsicInst`.
Reviewers: pirama, efriedma, srhines
Reviewed By: efriedma
Subscribers: llvm-commits, javed.absar
Differential Revision: https://reviews.llvm.org/D34921
llvm-svn: 307587
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll | 31 | ||||
| -rw-r--r-- | llvm/test/Transforms/ConstantHoisting/ARM/insertvalue.ll | 31 |
2 files changed, 62 insertions, 0 deletions
diff --git a/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll b/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll index ffcfb2e56c9..315e69998c6 100644 --- a/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll +++ b/llvm/test/Transforms/ConstantHoisting/ARM/bad-cases.ll @@ -107,3 +107,34 @@ entry: %ret = add i32 %cast0, %cast1 ret i32 %ret } + +@exception_type = external global i8 + +; Constants in inline ASM should not be hoisted. +define i32 @inline_asm_invoke() personality i8* null { +;CHECK-LABEL: @inline_asm_invoke +;CHECK-NOT: %const = 214672 +;CHECK: %X = invoke i32 asm "bswap $0", "=r,r"(i32 214672) + %X = invoke i32 asm "bswap $0", "=r,r"(i32 214672) + to label %L unwind label %lpad +;CHECK: %Y = invoke i32 asm "bswap $0", "=r,r"(i32 214672) + %Y = invoke i32 asm "bswap $0", "=r,r"(i32 214672) + to label %L unwind label %lpad +L: + ret i32 %X +lpad: + %lp = landingpad i32 + cleanup + catch i8* @exception_type + ret i32 1 +} + +define i32 @inline_asm_call() { +;CHECK-LABEL: @inline_asm_call +;CHECK-NOT: %const = 214672 +;CHECK: %X = call i32 asm "bswap $0", "=r,r"(i32 214672) + %X = call i32 asm "bswap $0", "=r,r"(i32 214672) +;CHECK: %Y = call i32 asm "bswap $0", "=r,r"(i32 214672) + %Y = call i32 asm "bswap $0", "=r,r"(i32 214672) + ret i32 %X +} diff --git a/llvm/test/Transforms/ConstantHoisting/ARM/insertvalue.ll b/llvm/test/Transforms/ConstantHoisting/ARM/insertvalue.ll new file mode 100644 index 00000000000..99fe7fbe22a --- /dev/null +++ b/llvm/test/Transforms/ConstantHoisting/ARM/insertvalue.ll @@ -0,0 +1,31 @@ +; RUN: opt -consthoist -S < %s | FileCheck %s +target triple = "thumbv6m-none-eabi" + +%T = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32 } + +; The second operand of insertvalue is able to be hoisted. +define void @test1(%T %P) { +; CHECK-LABEL: @test1 +; CHECK: %const = bitcast i32 256 to i32 +; CHECK: %1 = insertvalue %T %P, i32 %const, 256 +; CHECK: %2 = insertvalue %T %P, i32 %const, 256 + %1 = insertvalue %T %P, i32 256, 256 + %2 = insertvalue %T %P, i32 256, 256 + ret void +} |

