blob: bff2b88a5db11eecea7438dcdb97f2157a06cab8 [file] [log] [blame]
Chris Lattner5e488c92006-02-12 02:02:43 +00001; This file contains various testcases that check to see that instcombine
2; is narrowing computations when possible.
3
Reid Spencer985e52f2007-01-13 05:06:52 +00004; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \
5; RUN: grep 'ret i1 false'
Chris Lattner5e488c92006-02-12 02:02:43 +00006
7; test1 - Eliminating the casts in this testcase (by narrowing the AND
8; operation) allows instcombine to realize the function always returns false.
9;
10bool %test1(int %A, int %B) {
11 %C1 = setlt int %A, %B
Reid Spencer6c38f0b2006-11-27 01:05:10 +000012 %ELIM1 = zext bool %C1 to uint
Chris Lattner5e488c92006-02-12 02:02:43 +000013 %C2 = setgt int %A, %B
Reid Spencer6c38f0b2006-11-27 01:05:10 +000014 %ELIM2 = zext bool %C2 to uint
Chris Lattner5e488c92006-02-12 02:02:43 +000015 %C3 = and uint %ELIM1, %ELIM2
Reid Spencer6c38f0b2006-11-27 01:05:10 +000016 %ELIM3 = trunc uint %C3 to bool
Chris Lattner5e488c92006-02-12 02:02:43 +000017 ret bool %ELIM3
18}