summaryrefslogtreecommitdiffstats
path: root/test/Transforms/InstCombine/2008-11-20-DivMulRem.ll
blob: 8c58a2ae7f7d51cc090edad50426336e11a18416 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
; RUN: llvm-as < %s | opt -instcombine | llvm-dis > %t
; RUN: grep urem %t | count 3
; RUN: grep srem %t | count 1
; RUN: grep sub %t | count 2
; RUN: grep add %t | count 1
; PR3103

define i8 @test1(i8 %x, i8 %y) {
  %A = udiv i8 %x, %y
  %B = mul i8 %A, %y
  %C = sub i8 %x, %B
  ret i8 %C
}

define i8 @test2(i8 %x, i8 %y) {
  %A = sdiv i8 %x, %y
  %B = mul i8 %A, %y
  %C = sub i8 %x, %B
  ret i8 %C
}

define i8 @test3(i8 %x, i8 %y) {
  %A = udiv i8 %x, %y
  %B = mul i8 %A, %y
  %C = sub i8 %B, %x
  ret i8 %C
}

define i8 @test4(i8 %x) {
  %A = udiv i8 %x, 3
  %B = mul i8 %A, -3
  %C = sub i8 %x, %B
  ret i8 %C
}
OpenPOWER on IntegriCloud