1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -mtriple=aarch64-none-linux-gnu -mcpu=neoverse-n1 -verify-machineinstrs < %s | FileCheck %s
4 ; The tests check the following optimization of DAGCombiner for AArch64:
5 ; CMP(A,C)||CMP(B,C) => CMP(MIN/MAX(A,B), C)
6 ; CMP(A,C)&&CMP(B,C) => CMP(MIN/MAX(A,B), C)
8 define i1 @test1(float %arg1, float %arg2, float %arg3) #0 {
11 ; CHECK-NEXT: fminnm s0, s0, s1
12 ; CHECK-NEXT: fcmp s0, s2
13 ; CHECK-NEXT: cset w0, mi
15 %cmp1 = fcmp olt float %arg1, %arg3
16 %cmp2 = fcmp olt float %arg2, %arg3
17 %or1 = or i1 %cmp1, %cmp2
21 define i1 @test2(double %arg1, double %arg2, double %arg3) #0 {
24 ; CHECK-NEXT: fmaxnm d0, d0, d1
25 ; CHECK-NEXT: fcmp d0, d2
26 ; CHECK-NEXT: cset w0, gt
28 %cmp1 = fcmp ogt double %arg1, %arg3
29 %cmp2 = fcmp ogt double %arg2, %arg3
30 %or1 = or i1 %cmp1, %cmp2
34 define i1 @test3(float %arg1, float %arg2, float %arg3) {
37 ; CHECK-NEXT: fmov s3, #1.00000000
38 ; CHECK-NEXT: fadd s0, s0, s3
39 ; CHECK-NEXT: fmov s3, #2.00000000
40 ; CHECK-NEXT: fadd s1, s1, s3
41 ; CHECK-NEXT: fmaxnm s0, s0, s1
42 ; CHECK-NEXT: fcmp s0, s2
43 ; CHECK-NEXT: cset w0, lt
45 %add1 = fadd nnan float %arg1, 1.0
46 %add2 = fadd nnan float %arg2, 2.0
47 %cmp1 = fcmp nnan olt float %add1, %arg3
48 %cmp2 = fcmp nnan olt float %add2, %arg3
49 %or1 = and i1 %cmp1, %cmp2
53 define i1 @test4(float %arg1, float %arg2, float %arg3) {
56 ; CHECK-NEXT: fmov s3, #1.00000000
57 ; CHECK-NEXT: fadd s0, s0, s3
58 ; CHECK-NEXT: fmov s3, #2.00000000
59 ; CHECK-NEXT: fadd s1, s1, s3
60 ; CHECK-NEXT: fminnm s0, s0, s1
61 ; CHECK-NEXT: fcmp s0, s2
62 ; CHECK-NEXT: cset w0, gt
64 %add1 = fadd nnan float %arg1, 1.0
65 %add2 = fadd nnan float %arg2, 2.0
66 %cmp1 = fcmp nnan ogt float %add1, %arg3
67 %cmp2 = fcmp nnan ogt float %add2, %arg3
68 %or1 = and i1 %cmp1, %cmp2