blob: 02d7e31b8addc6a8893b5cb22b1000fa0a90ef5f [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.
Reid Spencer985e52f2007-01-13 05:06:52 +00003; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \
Reid Spencer91948d42007-04-14 20:13:02 +00004; RUN: grep {ret i1 false}
Chris Lattner5e488c92006-02-12 02:02:43 +00005
6; test1 - Eliminating the casts in this testcase (by narrowing the AND
7; operation) allows instcombine to realize the function always returns false.
8;
9bool %test1(int %A, int %B) {
10 %C1 = setlt int %A, %B
Reid Spencer6c38f0b2006-11-27 01:05:10 +000011 %ELIM1 = zext bool %C1 to uint
Chris Lattner5e488c92006-02-12 02:02:43 +000012 %C2 = setgt int %A, %B
Reid Spencer6c38f0b2006-11-27 01:05:10 +000013 %ELIM2 = zext bool %C2 to uint
Chris Lattner5e488c92006-02-12 02:02:43 +000014 %C3 = and uint %ELIM1, %ELIM2
Reid Spencer6c38f0b2006-11-27 01:05:10 +000015 %ELIM3 = trunc uint %C3 to bool
Chris Lattner5e488c92006-02-12 02:02:43 +000016 ret bool %ELIM3
17}