File: select.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 (44 lines) | stat: -rw-r--r-- 1,394 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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes=sccp -S | FileCheck %s

define i32 @test1(i1 %C) {
; CHECK-LABEL: define i32 @test1(
; CHECK-SAME: i1 [[C:%.*]]) {
; CHECK-NEXT:    ret i32 0
;
  %X = select i1 %C, i32 0, i32 0
  ret i32 %X
}

define i32 @test2(i1 %C) {
; CHECK-LABEL: define i32 @test2(
; CHECK-SAME: i1 [[C:%.*]]) {
; CHECK-NEXT:    ret i32 0
;
  %X = select i1 %C, i32 0, i32 undef
  ret i32 %X
}

define i1 @f2(i32 %x, i1 %cmp) {
; CHECK-LABEL: define i1 @f2(
; CHECK-SAME: i32 [[X:%.*]], i1 [[CMP:%.*]]) {
; CHECK-NEXT:    [[SEL_1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 10
; CHECK-NEXT:    [[C_1:%.*]] = icmp sgt i32 [[SEL_1]], 300
; CHECK-NEXT:    [[C_2:%.*]] = icmp sgt i32 [[SEL_1]], 100
; CHECK-NEXT:    [[C_3:%.*]] = icmp eq i32 [[SEL_1]], 50
; CHECK-NEXT:    [[C_4:%.*]] = icmp slt i32 [[SEL_1]], 9
; CHECK-NEXT:    [[RES_1:%.*]] = add i1 [[C_1]], [[C_2]]
; CHECK-NEXT:    [[RES_2:%.*]] = add i1 [[RES_1]], [[C_3]]
; CHECK-NEXT:    [[RES_3:%.*]] = add i1 [[RES_2]], [[C_4]]
; CHECK-NEXT:    ret i1 [[RES_3]]
;
  %sel.1 = select i1 %cmp, i32 %x, i32 10
  %c.1 = icmp sgt i32 %sel.1, 300
  %c.2 = icmp sgt i32 %sel.1, 100
  %c.3 = icmp eq i32 %sel.1, 50
  %c.4 = icmp slt i32 %sel.1, 9
  %res.1 = add i1 %c.1, %c.2
  %res.2 = add i1 %res.1, %c.3
  %res.3 = add i1 %res.2, %c.4
  ret i1 %res.3
}