Skip to content

[mlir][flang] add fast math attribute to fcmp #74315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions flang/include/flang/Optimizer/Dialect/FIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -2553,14 +2553,18 @@ def fir_DivcOp : ComplexArithmeticOp<"divc",
// Pow is a builtin call and not a primitive

def fir_CmpcOp : fir_Op<"cmpc",
[NoMemoryEffect, SameTypeOperands, SameOperandsAndResultShape]> {
[NoMemoryEffect, SameTypeOperands, SameOperandsAndResultShape,
DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
let summary = "complex floating-point comparison operator";

let description = [{
A complex comparison to handle complex types found in FIR.
}];

let arguments = (ins fir_ComplexType:$lhs, fir_ComplexType:$rhs);
let arguments = (ins
fir_ComplexType:$lhs,
fir_ComplexType:$rhs,
DefaultValuedAttr<Arith_FastMathAttr, "::mlir::arith::FastMathFlags::none">:$fastmath);

let results = (outs AnyLogicalLike);

Expand Down
18 changes: 10 additions & 8 deletions flang/lib/Optimizer/CodeGen/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,16 +840,18 @@ struct CmpcOpConversion : public FIROpConversion<fir::CmpcOp> {
mlir::ValueRange operands = adaptor.getOperands();
mlir::Type resTy = convertType(cmp.getType());
mlir::Location loc = cmp.getLoc();
llvm::SmallVector<mlir::Value, 2> rp = {
mlir::LLVM::FastmathFlags fmf =
mlir::arith::convertArithFastMathFlagsToLLVM(cmp.getFastmath());
mlir::LLVM::FCmpPredicate pred =
static_cast<mlir::LLVM::FCmpPredicate>(cmp.getPredicate());
auto rcp = rewriter.create<mlir::LLVM::FCmpOp>(
loc, resTy, pred,
rewriter.create<mlir::LLVM::ExtractValueOp>(loc, operands[0], 0),
rewriter.create<mlir::LLVM::ExtractValueOp>(loc, operands[1], 0)};
auto rcp =
rewriter.create<mlir::LLVM::FCmpOp>(loc, resTy, rp, cmp->getAttrs());
llvm::SmallVector<mlir::Value, 2> ip = {
rewriter.create<mlir::LLVM::ExtractValueOp>(loc, operands[1], 0), fmf);
auto icp = rewriter.create<mlir::LLVM::FCmpOp>(
loc, resTy, pred,
rewriter.create<mlir::LLVM::ExtractValueOp>(loc, operands[0], 1),
rewriter.create<mlir::LLVM::ExtractValueOp>(loc, operands[1], 1)};
auto icp =
rewriter.create<mlir::LLVM::FCmpOp>(loc, resTy, ip, cmp->getAttrs());
rewriter.create<mlir::LLVM::ExtractValueOp>(loc, operands[1], 1), fmf);
llvm::SmallVector<mlir::Value, 2> cp = {rcp, icp};
switch (cmp.getPredicate()) {
case mlir::arith::CmpFPredicate::OEQ: // .EQ.
Expand Down
10 changes: 5 additions & 5 deletions flang/test/Fir/convert-to-llvm.fir
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ func.func @compare_complex_eq(%a : !fir.complex<8>, %b : !fir.complex<8>) -> i1
// CHECK: return [[RES]] : i1

func.func @compare_complex_ne(%a : !fir.complex<8>, %b : !fir.complex<8>) -> i1 {
%r = fir.cmpc "une", %a, %b : !fir.complex<8>
%r = fir.cmpc "une", %a, %b {fastmath = #arith.fastmath<fast>} : !fir.complex<8>
return %r : i1
}

Expand All @@ -667,13 +667,13 @@ func.func @compare_complex_ne(%a : !fir.complex<8>, %b : !fir.complex<8>) -> i1
// CHECK-DAG: [[IA:%.*]] = llvm.extractvalue [[A]][1] : !llvm.struct<(f64, f64)>
// CHECK-DAG: [[RB:%.*]] = llvm.extractvalue [[B]][0] : !llvm.struct<(f64, f64)>
// CHECK-DAG: [[IB:%.*]] = llvm.extractvalue [[B]][1] : !llvm.struct<(f64, f64)>
// CHECK-DAG: [[RESR:%.*]] = llvm.fcmp "une" [[RA]], [[RB]] : f64
// CHECK-DAG: [[RESI:%.*]] = llvm.fcmp "une" [[IA]], [[IB]] : f64
// CHECK-DAG: [[RESR:%.*]] = llvm.fcmp "une" [[RA]], [[RB]] {fastmathFlags = #llvm.fastmath<fast>} : f64
// CHECK-DAG: [[RESI:%.*]] = llvm.fcmp "une" [[IA]], [[IB]] {fastmathFlags = #llvm.fastmath<fast>} : f64
// CHECK: [[RES:%.*]] = llvm.or [[RESR]], [[RESI]] : i1
// CHECK: return [[RES]] : i1

func.func @compare_complex_other(%a : !fir.complex<8>, %b : !fir.complex<8>) -> i1 {
%r = fir.cmpc "ogt", %a, %b : !fir.complex<8>
%r = fir.cmpc "ogt", %a, %b {fastmath = #arith.fastmath<fast>} : !fir.complex<8>
return %r : i1
}

Expand All @@ -682,7 +682,7 @@ func.func @compare_complex_other(%a : !fir.complex<8>, %b : !fir.complex<8>) ->
// CHECK-SAME: [[B:%.*]]: !llvm.struct<(f64, f64)>
// CHECK-DAG: [[RA:%.*]] = llvm.extractvalue [[A]][0] : !llvm.struct<(f64, f64)>
// CHECK-DAG: [[RB:%.*]] = llvm.extractvalue [[B]][0] : !llvm.struct<(f64, f64)>
// CHECK: [[RESR:%.*]] = llvm.fcmp "ogt" [[RA]], [[RB]] : f64
// CHECK: [[RESR:%.*]] = llvm.fcmp "ogt" [[RA]], [[RB]] {fastmathFlags = #llvm.fastmath<fast>} : f64
// CHECK: return [[RESR]] : i1

// -----
Expand Down
32 changes: 16 additions & 16 deletions flang/test/Fir/fir-ops.fir
Original file line number Diff line number Diff line change
Expand Up @@ -464,37 +464,37 @@ fir.type_info @test_type_info noinit nodestroy nofinal extends !fir.type<parent{
// CHECK-SAME: [[VAL_151:%.*]]: !fir.complex<16>, [[VAL_152:%.*]]: !fir.complex<16>) {
func.func @compare_complex(%a : !fir.complex<16>, %b : !fir.complex<16>) {

// CHECK: [[VAL_153:%.*]] = fir.cmpc "false", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_154:%.*]] = fir.cmpc "oeq", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_155:%.*]] = fir.cmpc "ogt", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_156:%.*]] = fir.cmpc "oge", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_153:%.*]] = fir.cmpc "false", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
// CHECK: [[VAL_154:%.*]] = fir.cmpc "oeq", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
// CHECK: [[VAL_155:%.*]] = fir.cmpc "ogt", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
// CHECK: [[VAL_156:%.*]] = fir.cmpc "oge", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
%d0 = fir.cmpc "false", %a, %b : !fir.complex<16>
%d1 = fir.cmpc "oeq", %a, %b : !fir.complex<16>
%d2 = fir.cmpc "ogt", %a, %b : !fir.complex<16>
%d3 = fir.cmpc "oge", %a, %b : !fir.complex<16>

// CHECK: [[VAL_157:%.*]] = fir.cmpc "olt", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_158:%.*]] = fir.cmpc "ole", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_159:%.*]] = fir.cmpc "one", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_160:%.*]] = fir.cmpc "ord", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_157:%.*]] = fir.cmpc "olt", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
// CHECK: [[VAL_158:%.*]] = fir.cmpc "ole", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
// CHECK: [[VAL_159:%.*]] = fir.cmpc "one", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
// CHECK: [[VAL_160:%.*]] = fir.cmpc "ord", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
%a0 = fir.cmpc "olt", %a, %b : !fir.complex<16>
%a1 = fir.cmpc "ole", %a, %b : !fir.complex<16>
%a2 = fir.cmpc "one", %a, %b : !fir.complex<16>
%a3 = fir.cmpc "ord", %a, %b : !fir.complex<16>

// CHECK: [[VAL_161:%.*]] = fir.cmpc "ueq", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_162:%.*]] = fir.cmpc "ugt", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_163:%.*]] = fir.cmpc "uge", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_164:%.*]] = fir.cmpc "ult", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_161:%.*]] = fir.cmpc "ueq", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
// CHECK: [[VAL_162:%.*]] = fir.cmpc "ugt", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
// CHECK: [[VAL_163:%.*]] = fir.cmpc "uge", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
// CHECK: [[VAL_164:%.*]] = fir.cmpc "ult", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
%b0 = fir.cmpc "ueq", %a, %b : !fir.complex<16>
%b1 = fir.cmpc "ugt", %a, %b : !fir.complex<16>
%b2 = fir.cmpc "uge", %a, %b : !fir.complex<16>
%b3 = fir.cmpc "ult", %a, %b : !fir.complex<16>

// CHECK: [[VAL_165:%.*]] = fir.cmpc "ule", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_166:%.*]] = fir.cmpc "une", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_167:%.*]] = fir.cmpc "uno", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_168:%.*]] = fir.cmpc "true", [[VAL_151]], [[VAL_152]] : !fir.complex<16>
// CHECK: [[VAL_165:%.*]] = fir.cmpc "ule", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
// CHECK: [[VAL_166:%.*]] = fir.cmpc "une", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
// CHECK: [[VAL_167:%.*]] = fir.cmpc "uno", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
// CHECK: [[VAL_168:%.*]] = fir.cmpc "true", [[VAL_151]], [[VAL_152]] {fastmath = {{.*}}} : !fir.complex<16>
%c0 = fir.cmpc "ule", %a, %b : !fir.complex<16>
%c1 = fir.cmpc "une", %a, %b : !fir.complex<16>
%c2 = fir.cmpc "uno", %a, %b : !fir.complex<16>
Expand Down
2 changes: 1 addition & 1 deletion flang/test/HLFIR/call_with_poly_dummy.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ end subroutine test1
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFtest2Ex"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_1]]#0 : !fir.ref<f32>
! CHECK: %[[VAL_3:.*]] = arith.constant 0.000000e+00 : f32
! CHECK: %[[VAL_4:.*]] = arith.cmpf oeq, %[[VAL_2]], %[[VAL_3]] : f32
! CHECK: %[[VAL_4:.*]] = arith.cmpf oeq, %[[VAL_2]], %[[VAL_3]] {{.*}} : f32
! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i1) -> !fir.logical<4>
! CHECK: %[[VAL_6:.*]]:3 = hlfir.associate %[[VAL_5]] {adapt.valuebyref} : (!fir.logical<4>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>, i1)
! CHECK: %[[VAL_7:.*]] = fir.embox %[[VAL_6]]#0 : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
Expand Down
4 changes: 2 additions & 2 deletions flang/test/Lower/HLFIR/binary-ops.f90
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ subroutine cmp_real(l, x, y)
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare {{.*}}y"
! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_4]]#0 : !fir.ref<f32>
! CHECK: %[[VAL_7:.*]] = fir.load %[[VAL_5]]#0 : !fir.ref<f32>
! CHECK: %[[VAL_8:.*]] = arith.cmpf oeq, %[[VAL_6]], %[[VAL_7]] : f32
! CHECK: %[[VAL_8:.*]] = arith.cmpf oeq, %[[VAL_6]], %[[VAL_7]] {{.*}} : f32

subroutine cmp_real_2(l, x, y)
logical :: l
Expand All @@ -273,7 +273,7 @@ subroutine cmp_cmplx(l, x, y)
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare {{.*}}y"
! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_4]]#0 : !fir.ref<!fir.complex<4>>
! CHECK: %[[VAL_7:.*]] = fir.load %[[VAL_5]]#0 : !fir.ref<!fir.complex<4>>
! CHECK: %[[VAL_8:.*]] = fir.cmpc "oeq", %[[VAL_6]], %[[VAL_7]] : !fir.complex<4>
! CHECK: %[[VAL_8:.*]] = fir.cmpc "oeq", %[[VAL_6]], %[[VAL_7]] {{.*}} : !fir.complex<4>

subroutine cmp_char(l, x, y)
logical :: l
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/HLFIR/user-defined-assignment.f90
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ subroutine test_non_elemental_array(x)
! CHECK: ^bb0(%[[VAL_7:.*]]: index):
! CHECK: %[[VAL_8:.*]] = hlfir.designate %[[VAL_1]]#0 (%[[VAL_7]]) : (!fir.box<!fir.array<?xf32>>, index) -> !fir.ref<f32>
! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_8]] : !fir.ref<f32>
! CHECK: %[[VAL_10:.*]] = arith.cmpf olt, %[[VAL_9]], %[[VAL_2]] : f32
! CHECK: %[[VAL_10:.*]] = arith.cmpf olt, %[[VAL_9]], %[[VAL_2]] {{.*}} : f32
! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i1) -> !fir.logical<4>
! CHECK: hlfir.yield_element %[[VAL_11]] : !fir.logical<4>
! CHECK: }
Expand Down
4 changes: 2 additions & 2 deletions flang/test/Lower/Intrinsics/bessel_jn.f90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ subroutine test_transformational_real4(x, n1, n2, r)
! ALL-DAG: %[[x:.*]] = fir.load %[[argx]] : !fir.ref<f32>
! ALL-DAG: %[[n1:.*]] = fir.load %[[argn1]] : !fir.ref<i32>
! ALL-DAG: %[[n2:.*]] = fir.load %[[argn2]] : !fir.ref<i32>
! ALL-DAG: %[[xeq0:.*]] = arith.cmpf ueq, %[[x]], %[[zero]] : f32
! ALL-DAG: %[[xeq0:.*]] = arith.cmpf ueq, %[[x]], %[[zero]] {{.*}} : f32
! ALL-DAG: %[[n1ltn2:.*]] = arith.cmpi slt, %[[n1]], %[[n2]] : i32
! ALL-DAG: %[[n1eqn2:.*]] = arith.cmpi eq, %[[n1]], %[[n2]] : i32
! ALL: fir.if %[[xeq0]] {
Expand Down Expand Up @@ -85,7 +85,7 @@ subroutine test_transformational_real8(x, n1, n2, r)
! ALL-DAG: %[[x:.*]] = fir.load %[[argx]] : !fir.ref<f64>
! ALL-DAG: %[[n1:.*]] = fir.load %[[argn1]] : !fir.ref<i32>
! ALL-DAG: %[[n2:.*]] = fir.load %[[argn2]] : !fir.ref<i32>
! ALL-DAG: %[[xeq0:.*]] = arith.cmpf ueq, %[[x]], %[[zero]] : f64
! ALL-DAG: %[[xeq0:.*]] = arith.cmpf ueq, %[[x]], %[[zero]] {{.*}} : f64
! ALL-DAG: %[[n1ltn2:.*]] = arith.cmpi slt, %[[n1]], %[[n2]] : i32
! ALL-DAG: %[[n1eqn2:.*]] = arith.cmpi eq, %[[n1]], %[[n2]] : i32
! ALL: fir.if %[[xeq0]] {
Expand Down
4 changes: 2 additions & 2 deletions flang/test/Lower/Intrinsics/bessel_yn.f90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ subroutine test_transformational_real4(x, n1, n2, r)
! ALL-DAG: %[[x:.*]] = fir.load %[[argx]] : !fir.ref<f32>
! ALL-DAG: %[[n1:.*]] = fir.load %[[argn1]] : !fir.ref<i32>
! ALL-DAG: %[[n2:.*]] = fir.load %[[argn2]] : !fir.ref<i32>
! ALL-DAG: %[[xeq0:.*]] = arith.cmpf ueq, %[[x]], %[[zero]] : f32
! ALL-DAG: %[[xeq0:.*]] = arith.cmpf ueq, %[[x]], %[[zero]] {{.*}} : f32
! ALL-DAG: %[[n1ltn2:.*]] = arith.cmpi slt, %[[n1]], %[[n2]] : i32
! ALL-DAG: %[[n1eqn2:.*]] = arith.cmpi eq, %[[n1]], %[[n2]] : i32
! ALL: fir.if %[[xeq0]] {
Expand Down Expand Up @@ -85,7 +85,7 @@ subroutine test_transformational_real8(x, n1, n2, r)
! ALL-DAG: %[[x:.*]] = fir.load %[[argx]] : !fir.ref<f64>
! ALL-DAG: %[[n1:.*]] = fir.load %[[argn1]] : !fir.ref<i32>
! ALL-DAG: %[[n2:.*]] = fir.load %[[argn2]] : !fir.ref<i32>
! ALL-DAG: %[[xeq0:.*]] = arith.cmpf ueq, %[[x]], %[[zero]] : f64
! ALL-DAG: %[[xeq0:.*]] = arith.cmpf ueq, %[[x]], %[[zero]] {{.*}} : f64
! ALL-DAG: %[[n1ltn2:.*]] = arith.cmpi slt, %[[n1]], %[[n2]] : i32
! ALL-DAG: %[[n1eqn2:.*]] = arith.cmpi eq, %[[n1]], %[[n2]] : i32
! ALL: fir.if %[[xeq0]] {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/Intrinsics/dim.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ subroutine dim_testr(x, y, z)
! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_1]] : !fir.ref<f32>
! CHECK: %[[VAL_5:.*]] = arith.constant 0.000000e+00 : f32
! CHECK: %[[VAL_6:.*]] = arith.subf %[[VAL_3]], %[[VAL_4]] {{.*}}: f32
! CHECK: %[[VAL_7:.*]] = arith.cmpf ogt, %[[VAL_6]], %[[VAL_5]] : f32
! CHECK: %[[VAL_7:.*]] = arith.cmpf ogt, %[[VAL_6]], %[[VAL_5]] {{.*}} : f32
! CHECK: %[[VAL_8:.*]] = arith.select %[[VAL_7]], %[[VAL_6]], %[[VAL_5]] : f32
! CHECK: fir.store %[[VAL_8]] to %[[VAL_2]] : !fir.ref<f32>
! CHECK: return
Expand Down
4 changes: 2 additions & 2 deletions flang/test/Lower/Intrinsics/min.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ real function test(a, b, c)
! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<f32>
! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_5]]#0 : !fir.ref<f32>
! CHECK: %[[VAL_10:.*]] = fir.is_present %[[VAL_5]]#0 : (!fir.ref<f32>) -> i1
! CHECK: %[[VAL_11:.*]] = arith.cmpf olt, %[[VAL_8]], %[[VAL_9]] : f32
! CHECK: %[[VAL_11:.*]] = arith.cmpf olt, %[[VAL_8]], %[[VAL_9]] {{.*}} : f32
! CHECK: %[[VAL_12:.*]] = arith.select %[[VAL_11]], %[[VAL_8]], %[[VAL_9]] : f32
! CHECK: %[[VAL_13:.*]] = fir.if %[[VAL_10]] -> (f32) {
! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_5]]#0 : !fir.ref<f32>
! CHECK: %[[VAL_15:.*]] = arith.cmpf olt, %[[VAL_12]], %[[VAL_14]] : f32
! CHECK: %[[VAL_15:.*]] = arith.cmpf olt, %[[VAL_12]], %[[VAL_14]] {{.*}} : f32
! CHECK: %[[VAL_16:.*]] = arith.select %[[VAL_15]], %[[VAL_12]], %[[VAL_14]] : f32
! CHECK: fir.result %[[VAL_16]] : f32
! CHECK: } else {
Expand Down
6 changes: 3 additions & 3 deletions flang/test/Lower/Intrinsics/modulo.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ subroutine modulo_testr(r, a, p)
! CHECK-DAG: %[[p:.*]] = fir.load %[[arg2]] : !fir.ref<f64>
! CHECK-DAG: %[[rem:.*]] = arith.remf %[[a]], %[[p]] {{.*}}: f64
! CHECK-DAG: %[[zero:.*]] = arith.constant 0.000000e+00 : f64
! CHECK-DAG: %[[remNotZero:.*]] = arith.cmpf une, %[[rem]], %[[zero]] : f64
! CHECK-DAG: %[[aNeg:.*]] = arith.cmpf olt, %[[a]], %[[zero]] : f64
! CHECK-DAG: %[[pNeg:.*]] = arith.cmpf olt, %[[p]], %[[zero]] : f64
! CHECK-DAG: %[[remNotZero:.*]] = arith.cmpf une, %[[rem]], %[[zero]] {{.*}} : f64
! CHECK-DAG: %[[aNeg:.*]] = arith.cmpf olt, %[[a]], %[[zero]] {{.*}} : f64
! CHECK-DAG: %[[pNeg:.*]] = arith.cmpf olt, %[[p]], %[[zero]] {{.*}} : f64
! CHECK-DAG: %[[signDifferent:.*]] = arith.xori %[[aNeg]], %[[pNeg]] : i1
! CHECK-DAG: %[[mustAddP:.*]] = arith.andi %[[remNotZero]], %[[signDifferent]] : i1
! CHECK-DAG: %[[remPlusP:.*]] = arith.addf %[[rem]], %[[p]] {{.*}}: f64
Expand Down
10 changes: 5 additions & 5 deletions flang/test/Lower/Intrinsics/nearest.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ subroutine nearest_test1(x, s)
! CHECK: %[[x:.*]] = fir.load %arg0 : !fir.ref<f32>
! CHECK: %[[s:.*]] = fir.load %arg1 : !fir.ref<f32>
! CHECK: %[[zero:.*]] = arith.constant 0.000000e+00 : f32
! CHECK: %[[cmp:.*]] = arith.cmpf ogt, %[[s]], %[[zero]] : f32
! CHECK: %[[cmp:.*]] = arith.cmpf ogt, %[[s]], %[[zero]] {{.*}} : f32
! CHECK: %[[pos:.*]] = arith.select %[[cmp]], %true, %false : i1
res = nearest(x, s)
! CHECK: %[[tmp:.*]] = fir.call @_FortranANearest4(%[[x]], %[[pos]]) {{.*}}: (f32, i1) -> f32
Expand All @@ -21,7 +21,7 @@ subroutine nearest_test2(x, s)
! CHECK: %[[x:.*]] = fir.load %arg0 : !fir.ref<f64>
! CHECK: %[[s:.*]] = fir.load %arg1 : !fir.ref<f64>
! CHECK: %[[zero:.*]] = arith.constant 0.000000e+00 : f64
! CHECK: %[[cmp:.*]] = arith.cmpf ogt, %[[s]], %[[zero]] : f64
! CHECK: %[[cmp:.*]] = arith.cmpf ogt, %[[s]], %[[zero]] {{.*}} : f64
! CHECK: %[[pos:.*]] = arith.select %[[cmp]], %true, %false : i1
res = nearest(x, s)
! CHECK: %[[tmp:.*]] = fir.call @_FortranANearest8(%[[x]], %[[pos]]) {{.*}}: (f64, i1) -> f64
Expand All @@ -35,7 +35,7 @@ subroutine nearest_test3(x, s)
! CHECK: %[[x:.*]] = fir.load %arg0 : !fir.ref<f80>
! CHECK: %[[s:.*]] = fir.load %arg1 : !fir.ref<f80>
! CHECK: %[[zero:.*]] = arith.constant 0.000000e+00 : f80
! CHECK: %[[cmp:.*]] = arith.cmpf ogt, %[[s]], %[[zero]] : f80
! CHECK: %[[cmp:.*]] = arith.cmpf ogt, %[[s]], %[[zero]] {{.*}} : f80
! CHECK: %[[pos:.*]] = arith.select %[[cmp]], %true, %false : i1
res = nearest(x, s)
! CHECK: %[[tmp:.*]] = fir.call @_FortranANearest10(%[[x]], %[[pos]]) {{.*}}: (f80, i1) -> f80
Expand All @@ -49,7 +49,7 @@ subroutine nearest_test4(x, s)
! CHECK: %[[x:.*]] = fir.load %arg0 : !fir.ref<f128>
! CHECK: %[[s:.*]] = fir.load %arg1 : !fir.ref<f128>
! CHECK: %[[zero:.*]] = arith.constant 0.000000e+00 : f128
! CHECK: %[[cmp:.*]] = arith.cmpf ogt, %[[s]], %[[zero]] : f128
! CHECK: %[[cmp:.*]] = arith.cmpf ogt, %[[s]], %[[zero]] {{.*}} : f128
! CHECK: %[[pos:.*]] = arith.select %[[cmp]], %true, %false : i1
res = nearest(x, s)
! CHECK: %[[tmp:.*]] = fir.call @_FortranANearest16(%[[x]], %[[pos]]) {{.*}}: (f128, i1) -> f128
Expand All @@ -64,7 +64,7 @@ subroutine nearest_test5(x, s)
real :: s
! CHECK: %[[s:.*]] = fir.load %arg1 : !fir.ref<f32>
! CHECK: %[[zero:.*]] = arith.constant 0.000000e+00 : f32
! CHECK: %[[cmp:.*]] = arith.cmpf ogt, %[[s]], %[[zero]] : f32
! CHECK: %[[cmp:.*]] = arith.cmpf ogt, %[[s]], %[[zero]] {{.*}} : f32
! CHECK: %[[pos:.*]] = arith.select %[[cmp]], %true, %false : i1
res = nearest(x, s)
! CHECK: %[[tmp:.*]] = fir.call @_FortranANearest16(%[[x]], %[[pos]]) {{.*}}: (f128, i1) -> f128
Expand Down
Loading