mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 10:56:06 +00:00

This patch adds upstreams support for BinOp including lvalue assignments. Note that this does not include ternary ops, BinOpOverflowOp, pointer arithmetic, ShiftOp and SelectOp which are required for logical binary operators. --------- Co-authored-by: Morris Hafner <mhafner@nvidia.com> Co-authored-by: Andy Kaylor <akaylor@nvidia.com>
34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -O1 -Wno-unused-value -fclangir -emit-cir %s -o %t.cir
|
|
// RUN: FileCheck --input-file=%t.cir %s
|
|
|
|
void b0(int a, int b) {
|
|
int x = a * b;
|
|
x = x / b;
|
|
x = x % b;
|
|
x = x + b;
|
|
x = x - b;
|
|
x = x & b;
|
|
x = x ^ b;
|
|
x = x | b;
|
|
}
|
|
|
|
// CHECK: %{{.+}} = cir.binop(mul, %{{.+}}, %{{.+}}) nsw : !s32i
|
|
// CHECK: %{{.+}} = cir.binop(div, %{{.+}}, %{{.+}}) : !s32i
|
|
// CHECK: %{{.+}} = cir.binop(rem, %{{.+}}, %{{.+}}) : !s32i
|
|
// CHECK: %{{.+}} = cir.binop(add, %{{.+}}, %{{.+}}) nsw : !s32i
|
|
// CHECK: %{{.+}} = cir.binop(sub, %{{.+}}, %{{.+}}) nsw : !s32i
|
|
// CHECK: %{{.+}} = cir.binop(and, %{{.+}}, %{{.+}}) : !s32i
|
|
// CHECK: %{{.+}} = cir.binop(xor, %{{.+}}, %{{.+}}) : !s32i
|
|
// CHECK: %{{.+}} = cir.binop(or, %{{.+}}, %{{.+}}) : !s32i
|
|
|
|
void testFloatingPointBinOps(float a, float b) {
|
|
a * b;
|
|
// CHECK: cir.binop(mul, %{{.+}}, %{{.+}}) : !cir.float
|
|
a / b;
|
|
// CHECK: cir.binop(div, %{{.+}}, %{{.+}}) : !cir.float
|
|
a + b;
|
|
// CHECK: cir.binop(add, %{{.+}}, %{{.+}}) : !cir.float
|
|
a - b;
|
|
// CHECK: cir.binop(sub, %{{.+}}, %{{.+}}) : !cir.float
|
|
}
|