diff options
author | Duncan Sands <baldrick@free.fr> | 2010-12-21 13:32:22 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2010-12-21 13:32:22 +0000 |
commit | 3421d908539cc489d2b1dac67d8cbc07160b01db (patch) | |
tree | 7fca8a20ec97f1b5a9c78cc5fb30954b72030f46 /test/Transforms/InstSimplify | |
parent | 0312a93693abc2eb682b2b101c889959888fd883 (diff) | |
download | external_llvm-3421d908539cc489d2b1dac67d8cbc07160b01db.zip external_llvm-3421d908539cc489d2b1dac67d8cbc07160b01db.tar.gz external_llvm-3421d908539cc489d2b1dac67d8cbc07160b01db.tar.bz2 |
Teach InstructionSimplify about distributive laws. These transforms fire
quite often, but don't make much difference in practice presumably because
instcombine also knows them and more.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122328 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstSimplify')
-rw-r--r-- | test/Transforms/InstSimplify/2010-12-20-Distribute.ll | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/Transforms/InstSimplify/2010-12-20-Distribute.ll b/test/Transforms/InstSimplify/2010-12-20-Distribute.ll new file mode 100644 index 0000000..4625698 --- /dev/null +++ b/test/Transforms/InstSimplify/2010-12-20-Distribute.ll @@ -0,0 +1,21 @@ +; RUN: opt < %s -instsimplify -S | FileCheck %s + +define i32 @factorize(i32 %x, i32 %y) { +; CHECK: @factorize +; (X | 2) & (X | 2) -> X | (1 & 2) -> X + %l = or i32 %x, 1 + %r = or i32 %x, 2 + %z = and i32 %l, %r + ret i32 %z +; CHECK: ret i32 %x +} + +define i32 @expand(i32 %x) { +; CHECK: @expand +; ((X & 1) | 2) & 1 -> ((X & 1) & 1) | (2 & 1) -> (X & 1) | 0 -> X & 1 + %a = and i32 %x, 1 + %b = or i32 %a, 2 + %c = and i32 %b, 1 + ret i32 %c +; CHECK: ret i32 %a +} |