File: combine_andor_with_cmps.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (71 lines) | stat: -rw-r--r-- 2,197 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
; RUN: llc -mtriple=aarch64-none-linux-gnu -mcpu=neoverse-n1 -verify-machineinstrs < %s | FileCheck %s

; The tests check the following optimization of DAGCombiner for AArch64:
; CMP(A,C)||CMP(B,C) => CMP(MIN/MAX(A,B), C)
; CMP(A,C)&&CMP(B,C) => CMP(MIN/MAX(A,B), C)

define i1 @test1(float %arg1, float %arg2, float %arg3) #0 {
; CHECK-LABEL: test1:
; CHECK:       // %bb.0:
; CHECK-NEXT:    fminnm s0, s0, s1
; CHECK-NEXT:    fcmp s0, s2
; CHECK-NEXT:    cset w0, mi
; CHECK-NEXT:    ret
  %cmp1 = fcmp olt float %arg1, %arg3
  %cmp2 = fcmp olt float %arg2, %arg3
  %or1  = or i1 %cmp1, %cmp2
  ret i1 %or1
}

define i1 @test2(double %arg1, double %arg2, double %arg3) #0 {
; CHECK-LABEL: test2:
; CHECK:       // %bb.0:
; CHECK-NEXT:    fmaxnm d0, d0, d1
; CHECK-NEXT:    fcmp d0, d2
; CHECK-NEXT:    cset w0, gt
; CHECK-NEXT:    ret
  %cmp1 = fcmp ogt double %arg1, %arg3
  %cmp2 = fcmp ogt double %arg2, %arg3
  %or1  = or i1 %cmp1, %cmp2
  ret i1 %or1
}

define i1 @test3(float %arg1, float %arg2, float %arg3) {
; CHECK-LABEL: test3:
; CHECK:       // %bb.0:
; CHECK-NEXT:    fmov s3, #1.00000000
; CHECK-NEXT:    fadd s0, s0, s3
; CHECK-NEXT:    fmov s3, #2.00000000
; CHECK-NEXT:    fadd s1, s1, s3
; CHECK-NEXT:    fmaxnm s0, s0, s1
; CHECK-NEXT:    fcmp s0, s2
; CHECK-NEXT:    cset w0, lt
; CHECK-NEXT:    ret
  %add1 = fadd nnan float %arg1, 1.0
  %add2 = fadd nnan float %arg2, 2.0
  %cmp1 = fcmp nnan olt float %add1, %arg3
  %cmp2 = fcmp nnan olt float %add2, %arg3
  %or1  = and i1 %cmp1, %cmp2
  ret i1 %or1
}

define i1 @test4(float %arg1, float %arg2, float %arg3) {
; CHECK-LABEL: test4:
; CHECK:       // %bb.0:
; CHECK-NEXT:    fmov s3, #1.00000000
; CHECK-NEXT:    fadd s0, s0, s3
; CHECK-NEXT:    fmov s3, #2.00000000
; CHECK-NEXT:    fadd s1, s1, s3
; CHECK-NEXT:    fminnm s0, s0, s1
; CHECK-NEXT:    fcmp s0, s2
; CHECK-NEXT:    cset w0, gt
; CHECK-NEXT:    ret
  %add1 = fadd nnan float %arg1, 1.0
  %add2 = fadd nnan float %arg2, 2.0
  %cmp1 = fcmp nnan ogt float %add1, %arg3
  %cmp2 = fcmp nnan ogt float %add2, %arg3
  %or1  = and i1 %cmp1, %cmp2
  ret i1 %or1
}