mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
8476e6e250
In LLVM IR the following code: %r = urem <ty> %t, %b is equivalent to: %q = udiv <ty> %t, %b %s = mul <ty> nuw %q, %b %r = sub <ty> nuw %t, %q ; (t / b) * b + (t % b) = t As UDiv, Mul and Sub are already supported by SCEV, URem can be implemented with minimal effort this way. Note: While SRem and SDiv are also related this way, SCEV does not provides SDiv yet. llvm-svn: 306695
16 lines
299 B
LLVM
16 lines
299 B
LLVM
; RUN: opt < %s -scalar-evolution -analyze | FileCheck %s
|
|
|
|
define i8 @foo(i8 %a) {
|
|
%t0 = urem i8 %a, 27
|
|
; CHECK: %t0
|
|
; CHECK-NEXT: --> ((-27 * (%a /u 27)) + %a)
|
|
ret i8 %t0
|
|
}
|
|
|
|
define i8 @bar(i8 %a) {
|
|
%t1 = urem i8 %a, 1
|
|
; CHECK: %t1
|
|
; CHECK-NEXT: --> 0
|
|
ret i8 %t1
|
|
}
|