mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-29 10:32:47 +00:00
0c73079855
a subtract is cheaper than a multiply. This generalizes an existing transform. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59800 91177308-0d34-0410-b5e6-96231b3b80d8
35 lines
622 B
LLVM
35 lines
622 B
LLVM
; 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
|
|
}
|