File: narrow.ll

package info (click to toggle)
llvm-toolchain-3.7 1%3A3.7.1-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 345,556 kB
  • ctags: 362,199
  • sloc: cpp: 2,156,381; ansic: 458,339; objc: 91,547; python: 89,988; asm: 86,305; sh: 21,479; makefile: 6,853; perl: 5,601; ml: 5,458; pascal: 3,933; lisp: 2,429; xml: 686; cs: 239; php: 202; csh: 117
file content (18 lines) | stat: -rw-r--r-- 788 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
; This file contains various testcases that check to see that instcombine
; is narrowing computations when possible.
; RUN: opt < %s -instcombine -S | \
; RUN:    grep "ret i1 false"

; test1 - Eliminating the casts in this testcase (by narrowing the AND
; operation) allows instcombine to realize the function always returns false.
;
define i1 @test1(i32 %A, i32 %B) {
        %C1 = icmp slt i32 %A, %B               ; <i1> [#uses=1]
        %ELIM1 = zext i1 %C1 to i32             ; <i32> [#uses=1]
        %C2 = icmp sgt i32 %A, %B               ; <i1> [#uses=1]
        %ELIM2 = zext i1 %C2 to i32             ; <i32> [#uses=1]
        %C3 = and i32 %ELIM1, %ELIM2            ; <i32> [#uses=1]
        %ELIM3 = trunc i32 %C3 to i1            ; <i1> [#uses=1]
        ret i1 %ELIM3
}