llvm/llvm/test/CodeGen/AArch64/GlobalISel/combine-cannonicalize-fcmp.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -o - -mtriple=aarch64-unknown-unknown -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs  %s | FileCheck %s --check-prefixes=CHECK

---
name:            test_fcmp_canon
body:             |
  bb.1:
    ; CHECK-LABEL: name: test_fcmp_canon
    ; CHECK: %lhs:_(s64) = G_FCONSTANT double 1.000000e+00
    ; CHECK-NEXT: %rhs:_(s64) = COPY $x0
    ; CHECK-NEXT: %res:_(s32) = afn G_FCMP floatpred(ole), %rhs(s64), %lhs
    ; CHECK-NEXT: $w0 = COPY %res(s32)
    %lhs:_(s64) = G_FCONSTANT double 1.0
    %rhs:_(s64) = COPY $x0
    %res:_(s32) = afn G_FCMP floatpred(oge), %lhs(s64), %rhs
    $w0 = COPY %res(s32)
...
---
name:            test_fcmp_no_canon
body:             |
  bb.1:
    ; CHECK-LABEL: name: test_fcmp_no_canon
    ; CHECK: %lhs:_(s64) = COPY $x0
    ; CHECK-NEXT: %rhs:_(s64) = G_FCONSTANT double 1.000000e+00
    ; CHECK-NEXT: %res:_(s32) = afn G_FCMP floatpred(oge), %lhs(s64), %rhs
    ; CHECK-NEXT: $w0 = COPY %res(s32)
    %lhs:_(s64) = COPY $x0
    %rhs:_(s64) = G_FCONSTANT double 1.0
    %res:_(s32) = afn G_FCMP floatpred(oge), %lhs(s64), %rhs
    $w0 = COPY %res(s32)
...
---
name:            test_fcmp_no_canon_bv
body:             |
  bb.1:
    ; CHECK-LABEL: name: test_fcmp_no_canon_bv
    ; CHECK: %opaque1:_(s64) = COPY $x0
    ; CHECK-NEXT: %opaque2:_(s64) = COPY $x0
    ; CHECK-NEXT: %const1:_(s64) = G_FCONSTANT double 1.000000e+00
    ; CHECK-NEXT: %const2:_(s64) = G_FCONSTANT double 2.000000e+00
    ; CHECK-NEXT: %lhs:_(<2 x s64>) = G_BUILD_VECTOR %const1(s64), %opaque2(s64)
    ; CHECK-NEXT: %rhs:_(<2 x s64>) = G_BUILD_VECTOR %opaque1(s64), %const2(s64)
    ; CHECK-NEXT: %res:_(<2 x s32>) = afn G_FCMP floatpred(oge), %lhs(<2 x s64>), %rhs
    ; CHECK-NEXT: $x0 = COPY %res(<2 x s32>)
    %opaque1:_(s64) = COPY $x0
    %opaque2:_(s64) = COPY $x0
    %const1:_(s64) = G_FCONSTANT double 1.0
    %const2:_(s64) = G_FCONSTANT double 2.0
    %lhs:_(<2 x s64>) = G_BUILD_VECTOR %const1(s64), %opaque2(s64)
    %rhs:_(<2 x s64>) = G_BUILD_VECTOR %opaque1(s64), %const2(s64)
    %res:_(<2 x s32>) = afn G_FCMP floatpred(oge), %lhs(<2 x s64>), %rhs
    $x0 = COPY %res(<2 x s32>)
...
---
name:            test_fcmp_canon_bv
body:             |
  bb.1:
    ; CHECK-LABEL: name: test_fcmp_canon_bv
    ; CHECK: %opaque1:_(s64) = COPY $x0
    ; CHECK-NEXT: %opaque2:_(s64) = COPY $x0
    ; CHECK-NEXT: %const1:_(s64) = G_FCONSTANT double 1.000000e+00
    ; CHECK-NEXT: %const2:_(s64) = G_FCONSTANT double 2.000000e+00
    ; CHECK-NEXT: %lhs:_(<2 x s64>) = G_BUILD_VECTOR %const1(s64), %const2(s64)
    ; CHECK-NEXT: %rhs:_(<2 x s64>) = G_BUILD_VECTOR %opaque1(s64), %opaque2(s64)
    ; CHECK-NEXT: %res:_(<2 x s32>) = afn G_FCMP floatpred(ole), %rhs(<2 x s64>), %lhs
    ; CHECK-NEXT: $x0 = COPY %res(<2 x s32>)
    %opaque1:_(s64) = COPY $x0
    %opaque2:_(s64) = COPY $x0
    %const1:_(s64) = G_FCONSTANT double 1.0
    %const2:_(s64) = G_FCONSTANT double 2.0
    %lhs:_(<2 x s64>) = G_BUILD_VECTOR %const1(s64), %const2(s64)
    %rhs:_(<2 x s64>) = G_BUILD_VECTOR %opaque1(s64), %opaque2(s64)
    %res:_(<2 x s32>) = afn G_FCMP floatpred(oge), %lhs(<2 x s64>), %rhs
    $x0 = COPY %res(<2 x s32>)
...
---
name:            test_fcmp_canon_splat
body:             |
  bb.1:
    ; CHECK-LABEL: name: test_fcmp_canon_splat
    ; CHECK: %const:_(s64) = G_FCONSTANT double 1.000000e+00
    ; CHECK-NEXT: %lhs:_(<vscale x 2 x s64>) = G_SPLAT_VECTOR %const(s64)
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x1
    ; CHECK-NEXT: %rhs:_(<vscale x 2 x s64>) = G_SPLAT_VECTOR [[COPY]](s64)
    ; CHECK-NEXT: %res:_(<vscale x 2 x s32>) = afn G_FCMP floatpred(ole), %rhs(<vscale x 2 x s64>), %lhs
    ; CHECK-NEXT: %z:_(<vscale x 2 x s64>) = G_ZEXT %res(<vscale x 2 x s32>)
    ; CHECK-NEXT: $z0 = COPY %z(<vscale x 2 x s64>)
    %const:_(s64) = G_FCONSTANT double 1.0
    %lhs:_(<vscale x 2 x s64>) = G_SPLAT_VECTOR %const:_(s64)
    %1:_(s64) = COPY $x1
    %rhs:_(<vscale x 2 x s64>) = G_SPLAT_VECTOR %1:_(s64)
    %res:_(<vscale x 2 x s32>) = afn G_FCMP floatpred(oge), %lhs(<vscale x 2 x s64>), %rhs
    %z:_(<vscale x 2 x s64>) = G_ZEXT  %res
    $z0 = COPY %z(<vscale x 2 x s64>)
...
---
name:            test_fcmp_const
body:             |
  bb.1:
    ; CHECK-LABEL: name: test_fcmp_const
    ; CHECK: %res:_(s32) = G_CONSTANT i32 0
    ; CHECK-NEXT: $w0 = COPY %res(s32)
    %lhs:_(s64) = G_FCONSTANT double 1.0
    %rhs:_(s64) = G_FCONSTANT double 2.0
    %res:_(s32) = afn G_FCMP floatpred(oge), %lhs(s64), %rhs
    $w0 = COPY %res(s32)
...
---
name:            test_fcmp_const_other
body:             |
  bb.1:
    ; CHECK-LABEL: name: test_fcmp_const_other
    ; CHECK: %res:_(s32) = G_CONSTANT i32 1
    ; CHECK-NEXT: $w0 = COPY %res(s32)
    %lhs:_(s64) = G_FCONSTANT double 2.0
    %rhs:_(s64) = G_FCONSTANT double 1.0
    %res:_(s32) = afn G_FCMP floatpred(oge), %lhs(s64), %rhs
    $w0 = COPY %res(s32)
...