1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-01 08:23:21 +01:00
llvm-mirror/test/Transforms/InstCombine/exact.ll
Chris Lattner 7b6a968f5d enhance vmcore to know that udiv's can be exact, and add a trivial
instcombine xform to exercise this.

Nothing forms exact udivs yet though.  This is progress on PR8862

llvm-svn: 124992
2011-02-06 21:44:57 +00:00

61 lines
1.0 KiB
LLVM

; RUN: opt < %s -instcombine -S | FileCheck %s
; CHECK: define i32 @foo
; CHECK: sdiv i32 %x, 8
define i32 @foo(i32 %x) {
%y = sdiv i32 %x, 8
ret i32 %y
}
; CHECK: define i32 @bar
; CHECK: ashr i32 %x, 3
define i32 @bar(i32 %x) {
%y = sdiv exact i32 %x, 8
ret i32 %y
}
; CHECK: i32 @a0
; CHECK: %y = srem i32 %x, 3
; CHECK: %z = sub i32 %x, %y
; CHECK: ret i32 %z
define i32 @a0(i32 %x) {
%y = sdiv i32 %x, 3
%z = mul i32 %y, 3
ret i32 %z
}
; CHECK: i32 @b0
; CHECK: ret i32 %x
define i32 @b0(i32 %x) {
%y = sdiv exact i32 %x, 3
%z = mul i32 %y, 3
ret i32 %z
}
; CHECK: i32 @a1
; CHECK: %y = srem i32 %x, 3
; CHECK: %z = sub i32 %y, %x
; CHECK: ret i32 %z
define i32 @a1(i32 %x) {
%y = sdiv i32 %x, 3
%z = mul i32 %y, -3
ret i32 %z
}
; CHECK: i32 @b1
; CHECK: %z = sub i32 0, %x
; CHECK: ret i32 %z
define i32 @b1(i32 %x) {
%y = sdiv exact i32 %x, 3
%z = mul i32 %y, -3
ret i32 %z
}
; CHECK: i32 @b2
; CHECK: ret i32 %x
define i32 @b2(i32 %x, i32 %w) {
%y = udiv exact i32 %x, %w
%z = mul i32 %y, %w
ret i32 %z
}