projects
/
oota-llvm.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Teach InstructionSimplify about distributive laws. These transforms fire
[oota-llvm.git]
/
test
/
Transforms
/
InstSimplify
/
2010-12-20-Distribute.ll
1
; RUN: opt < %s -instsimplify -S | FileCheck %s
2
3
define i32 @factorize(i32 %x, i32 %y) {
4
; CHECK: @factorize
5
; (X | 2) & (X | 2) -> X | (1 & 2) -> X
6
%l = or i32 %x, 1
7
%r = or i32 %x, 2
8
%z = and i32 %l, %r
9
ret i32 %z
10
; CHECK: ret i32 %x
11
}
12
13
define i32 @expand(i32 %x) {
14
; CHECK: @expand
15
; ((X & 1) | 2) & 1 -> ((X & 1) & 1) | (2 & 1) -> (X & 1) | 0 -> X & 1
16
%a = and i32 %x, 1
17
%b = or i32 %a, 2
18
%c = and i32 %b, 1
19
ret i32 %c
20
; CHECK: ret i32 %a
21
}