diff options
author | Duncan Sands <baldrick@free.fr> | 2010-11-23 14:23:47 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2010-11-23 14:23:47 +0000 |
commit | adc7771f18c09d50742ee0e07584aa92404b2144 (patch) | |
tree | 4c90d5f65011fdbc085f0c391e71a45f576792b2 /llvm/test/Transforms/InstCombine/2010-11-23-Distributed.ll | |
parent | e1b6c273b82609a83b5aa07a70a2941ce731f7c6 (diff) | |
download | bcm5719-llvm-adc7771f18c09d50742ee0e07584aa92404b2144.tar.gz bcm5719-llvm-adc7771f18c09d50742ee0e07584aa92404b2144.zip |
Exploit distributive laws (eg: And distributes over Or, Mul over Add, etc) in a
fairly systematic way in instcombine. Some of these cases were already dealt
with, in which case I removed the existing code. The case of Add has a bunch of
funky logic which covers some of this plus a few variants (considers shifts to be
a form of multiplication), which I didn't touch. The simplification performed is:
A*B+A*C -> A*(B+C). The improvement is to do this in cases that were not already
handled [such as A*B-A*C -> A*(B-C), which was reported on the mailing list], and
also to do it more often by not checking for "only one use" if "B+C" simplifies.
llvm-svn: 120024
Diffstat (limited to 'llvm/test/Transforms/InstCombine/2010-11-23-Distributed.ll')
-rw-r--r-- | llvm/test/Transforms/InstCombine/2010-11-23-Distributed.ll | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/2010-11-23-Distributed.ll b/llvm/test/Transforms/InstCombine/2010-11-23-Distributed.ll new file mode 100644 index 00000000000..13a5720dad2 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/2010-11-23-Distributed.ll @@ -0,0 +1,11 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s +define i32 @foo(i32 %x, i32 %y) { +; CHECK: @foo + %add = add nsw i32 %y, %x + %mul = mul nsw i32 %add, %y + %square = mul nsw i32 %y, %y + %res = sub i32 %mul, %square +; CHECK: %res = mul i32 %x, %y + ret i32 %res +; CHECK: ret i32 %res +} |