Exploit distributive laws (eg: And distributes over Or, Mul over Add, etc) in a
[oota-llvm.git] / test / Transforms / InstCombine / 2010-11-23-Distributed.ll
1 ; RUN: opt < %s -instcombine -S | FileCheck %s
2 define i32 @foo(i32 %x, i32 %y) {
3 ; CHECK: @foo
4   %add = add nsw i32 %y, %x
5   %mul = mul nsw i32 %add, %y
6   %square = mul nsw i32 %y, %y
7   %res = sub i32 %mul, %square
8 ; CHECK: %res = mul i32 %x, %y
9   ret i32 %res
10 ; CHECK: ret i32 %res
11 }