From b109b5c148ff60ea8f1105aadb2c31761ca3d445 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 21 Dec 2009 06:03:05 +0000 Subject: give instcombine some helper functions for matching MIN and MAX, and implement some optimizations for MIN(MIN()) and MAX(MAX()) and MIN(MAX()) etc. This substantially improves the code in PR5822 but doesn't kick in much elsewhere. 2 max's were optimized in pairlocalalign and one in smg2000. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91814 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/select.ll | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'test/Transforms/InstCombine/select.ll') diff --git a/test/Transforms/InstCombine/select.ll b/test/Transforms/InstCombine/select.ll index 565cfa57ff..7c597007c3 100644 --- a/test/Transforms/InstCombine/select.ll +++ b/test/Transforms/InstCombine/select.ll @@ -382,3 +382,43 @@ next: ; CHECK-NEXT: ret i32 %a } + +define i32 @test30(i32 %x, i32 %y) { + %cmp = icmp sgt i32 %x, %y + %cond = select i1 %cmp, i32 %x, i32 %y + %cmp5 = icmp sgt i32 %cond, %x + %retval = select i1 %cmp5, i32 %cond, i32 %x + ret i32 %retval +} + +define i32 @test31(i32 %x, i32 %y) { + %cmp = icmp ugt i32 %x, %y + %cond = select i1 %cmp, i32 %x, i32 %y + %cmp5 = icmp ugt i32 %cond, %x + %retval = select i1 %cmp5, i32 %cond, i32 %x + ret i32 %retval +} + +define i32 @test32(i32 %x, i32 %y) { + %cmp = icmp sgt i32 %x, %y + %cond = select i1 %cmp, i32 %y, i32 %x + %cmp5 = icmp sgt i32 %cond, %x + %retval = select i1 %cmp5, i32 %x, i32 %cond + ret i32 %retval +} + +define i32 @test33(i32 %x, i32 %y) { + %cmp = icmp sgt i32 %x, %y + %cond = select i1 %cmp, i32 %y, i32 %x + %cmp5 = icmp sgt i32 %cond, %x + %retval = select i1 %cmp5, i32 %cond, i32 %x + ret i32 %retval +} + +define i32 @test34(i32 %x, i32 %y) { + %cmp = icmp sgt i32 %x, %y + %cond = select i1 %cmp, i32 %x, i32 %y + %cmp5 = icmp sgt i32 %cond, %x + %retval = select i1 %cmp5, i32 %x, i32 %cond + ret i32 %retval +} -- cgit v1.2.3