The implementation is mostly based on the one existing for the nsw and nuw flags. If the exact flag is present, the corresponding operation returns a poison value when the result is not exact. (For a division, if rounding happens; for a right shift, if a non-zero bit is shifted out.)
15 lines
508 B
LLVM
15 lines
508 B
LLVM
; RUN: mlir-translate -import-llvm -split-input-file %s | FileCheck %s
|
|
|
|
; CHECK-LABEL: @exactflag_inst
|
|
define void @exactflag_inst(i64 %arg1, i64 %arg2) {
|
|
; CHECK: llvm.udiv exact %{{.*}}, %{{.*}} : i64
|
|
%1 = udiv exact i64 %arg1, %arg2
|
|
; CHECK: llvm.sdiv exact %{{.*}}, %{{.*}} : i64
|
|
%2 = sdiv exact i64 %arg1, %arg2
|
|
; CHECK: llvm.lshr exact %{{.*}}, %{{.*}} : i64
|
|
%3 = lshr exact i64 %arg1, %arg2
|
|
; CHECK: llvm.ashr exact %{{.*}}, %{{.*}} : i64
|
|
%4 = ashr exact i64 %arg1, %arg2
|
|
ret void
|
|
}
|