From: Chris Lattner Date: Thu, 28 Apr 2011 05:33:16 +0000 (+0000) Subject: move PR9803 to this readme. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=4c19b17a17ee1379b455f8dc4796af518dcb45e3;p=oota-llvm.git move PR9803 to this readme. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130385 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/README.txt b/lib/Target/X86/README.txt index 1902485c182..8237fbd0942 100644 --- a/lib/Target/X86/README.txt +++ b/lib/Target/X86/README.txt @@ -2032,3 +2032,31 @@ clamp_float: # @clamp_float with -ffast-math. //===---------------------------------------------------------------------===// + +This function (from PR9803): + +int clamp2(int a) { + if (a > 5) + a = 5; + if (a < 0) + return 0; + return a; +} + +Compiles to: + +_clamp2: ## @clamp2 + pushq %rbp + movq %rsp, %rbp + cmpl $5, %edi + movl $5, %ecx + cmovlel %edi, %ecx + testl %ecx, %ecx + movl $0, %eax + cmovnsl %ecx, %eax + popq %rbp + ret + +The move of 0 could be scheduled above the test to make it is xor reg,reg. + +//===---------------------------------------------------------------------===//