From 0bfd7fde43436ee810c3e50dc595330ec048c576 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 11 Sep 2006 23:00:56 +0000 Subject: [PATCH] Testcase noticed from PR906 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30269 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/README.txt | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/Target/X86/README.txt b/lib/Target/X86/README.txt index 98b58539f5a..394201c3c19 100644 --- a/lib/Target/X86/README.txt +++ b/lib/Target/X86/README.txt @@ -594,3 +594,37 @@ or eax, 2 cmp eax, 6 jz label +//===---------------------------------------------------------------------===// + +Compile: +int %test(ulong *%tmp) { + %tmp = load ulong* %tmp ; [#uses=1] + %tmp.mask = shr ulong %tmp, ubyte 50 ; [#uses=1] + %tmp.mask = cast ulong %tmp.mask to ubyte ; [#uses=1] + %tmp2 = and ubyte %tmp.mask, 3 ; [#uses=1] + %tmp2 = cast ubyte %tmp2 to int ; [#uses=1] + ret int %tmp2 +} + +to: + +_test: + movl 4(%esp), %eax + movl 4(%eax), %eax + shrl $18, %eax + andl $3, %eax + ret + +instead of: + +_test: + movl 4(%esp), %eax + movl 4(%eax), %eax + shrl $18, %eax + # TRUNCATE movb %al, %al + andb $3, %al + movzbl %al, %eax + ret + +This saves a movzbl, and saves a truncate if it doesn't get coallesced right. +This is a simple DAGCombine to propagate the zext through the and. -- 2.34.1