Fix some simple copy-paste errors in MBlaze ASM Parser and Makefile.
[oota-llvm.git] / lib / Target / X86 / README.txt
index 8237fbd094250af0315e0b7f200b985abd02e9eb..8d9eabad0be0a046ca1a00827bbc273ac96ef314 100644 (file)
@@ -1727,26 +1727,6 @@ are functionally identical.
 
 //===---------------------------------------------------------------------===//
 
-Take the following C code:
-int x(int y) { return (y & 63) << 14; }
-
-Code produced by gcc:
-       andl    $63, %edi
-       sall    $14, %edi
-       movl    %edi, %eax
-       ret
-
-Code produced by clang:
-       shll    $14, %edi
-       movl    %edi, %eax
-       andl    $1032192, %eax
-       ret
-
-The code produced by gcc is 3 bytes shorter.  This sort of construct often
-shows up with bitfields.
-
-//===---------------------------------------------------------------------===//
-
 Take the following C code:
 int f(int a, int b) { return (unsigned char)a == (unsigned char)b; }
 
@@ -2060,3 +2040,60 @@ _clamp2:                                ## @clamp2
 The move of 0 could be scheduled above the test to make it is xor reg,reg.
 
 //===---------------------------------------------------------------------===//
+
+GCC PR48986.  We currently compile this:
+
+void bar(void);
+void yyy(int* p) {
+    if (__sync_fetch_and_add(p, -1) == 1)
+      bar();
+}
+
+into:
+       movl    $-1, %eax
+       lock
+       xaddl   %eax, (%rdi)
+       cmpl    $1, %eax
+       je      LBB0_2
+
+Instead we could generate:
+
+       lock
+       dec %rdi
+       je LBB0_2
+
+The trick is to match "fetch_and_add(X, -C) == C".
+
+//===---------------------------------------------------------------------===//
+
+unsigned log2(unsigned x) {
+  return x > 1 ? 32-__builtin_clz(x-1) : 0;
+}
+
+generates (x86_64):
+       xorl    %eax, %eax
+       cmpl    $2, %edi
+       jb      LBB0_2
+## BB#1:
+       decl    %edi
+       movl    $63, %ecx
+       bsrl    %edi, %eax
+       cmovel  %ecx, %eax
+       xorl    $-32, %eax
+       addl    $33, %eax
+LBB0_2:
+       ret
+
+The cmov and the early test are redundant:
+       xorl    %eax, %eax
+       cmpl    $2, %edi
+       jb      LBB0_2
+## BB#1:
+       decl    %edi
+       bsrl    %edi, %eax
+       xorl    $-32, %eax
+       addl    $33, %eax
+LBB0_2:
+       ret
+
+//===---------------------------------------------------------------------===//