File: dagcombine-and-setcc.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 (48 lines) | stat: -rw-r--r-- 1,171 bytes parent folder | download | duplicates (15)
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
; RUN: llc < %s | FileCheck %s

target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.10.0"

; Function Attrs: nounwind
declare i32 @printf(ptr nocapture readonly, ...)

; On X86 1 is true and 0 is false, so we can't perform the combine:
; (and (setgt X,  true), (setgt Y,  true)) -> (setgt (or X, Y), true)
; This combine only works if the true value is -1.


;CHECK: cmpl
;CHECK: setl
;CHECK: cmpl
;CHECK: setl
;CHECK: orb
;CHECK: je

@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: optsize ssp uwtable
define i32 @foo(i32 %a, i32 %b, ptr %c) {
if.else429:
  %cmp.i1144 = icmp eq ptr %c, null
  %cmp430 = icmp slt i32 %a, 2
  %cmp432 = icmp slt i32 %b, 2
  %or.cond710 = or i1 %cmp430, %cmp432
  %or.cond710.not = xor i1 %or.cond710, true
  %brmerge1448 = or i1 %cmp.i1144, %or.cond710.not
  br i1 %brmerge1448, label %ret1, label %ret2

ret1:
  ret i32 0

ret2:
  ret i32 1
}

define i32 @main(i32 %argc, ptr nocapture readnone %argv) {
  %res = alloca i32, align 4
  %t = call i32 @foo(i32 1, i32 2, ptr %res) #3
  %v = call i32 (ptr, ...) @printf(ptr @.str, i32 %t)
  ret i32 0
}