26 lines · python
1# RUN: %PYTHON %s | FileCheck %s2from functools import partialmethod3 4from mlir.ir import *5import mlir.dialects.arith as arith6import mlir.dialects.func as func7import mlir.dialects.llvm as llvm8 9 10def run(f):11 print("\nTEST:", f.__name__)12 f()13 14 15# CHECK-LABEL: TEST: testOverflowFlags16# Test mostly to repro and verify error addressed for Python bindings.17@run18def testOverflowFlags():19 with Context() as ctx, Location.unknown():20 module = Module.create()21 with InsertionPoint(module.body):22 a = arith.ConstantOp(value=42, result=IntegerType.get_signless(32))23 r = arith.AddIOp(a, a, overflowFlags=arith.IntegerOverflowFlags.nsw)24 # CHECK: arith.addi {{.*}}, {{.*}} overflow<nsw> : i3225 print(r)26