[PATCH] D53521: [X86][BMI1] X86DAGToDAGISel: select BEXTR from x << (32 - y) >> (32 - y) pattern

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 22 12:45:54 PDT 2018


lebedev.ri added inline comments.


================
Comment at: test/CodeGen/X86/extract-lowbits.ll:2248
 ; X86-BMI1BMI2-NEXT:    movl {{[0-9]+}}(%esp), %ecx
-; X86-BMI1BMI2-NEXT:    bzhil %eax, (%ecx), %eax
+; X86-BMI1BMI2-NEXT:    bzhil %ecx, (%eax), %eax
 ; X86-BMI1BMI2-NEXT:    retl
----------------
This does **not** appear to be a miscompile:
```
$ /build/llvm-build-GCC-release/bin/llc -mtriple=i686-unknown-linux-gnu -mattr=+bmi,+tbm,+bmi2 test.ll -o -
        .text
        .file   "test.ll"
        .globl  bzhi32_d2_load          # -- Begin function bzhi32_d2_load
        .p2align        4, 0x90
        .type   bzhi32_d2_load, at function
bzhi32_d2_load:                         # @bzhi32_d2_load
# %bb.0:
        movl    4(%esp), %eax
        movl    8(%esp), %ecx
        bzhil   %ecx, (%eax), %eax
        retl
.Lfunc_end0:
        .size   bzhi32_d2_load, .Lfunc_end0-bzhi32_d2_load
                                        # -- End function

        .section        ".note.GNU-stack","", at progbits
$ llc-8 -mtriple=i686-unknown-linux-gnu -mattr=+bmi,+tbm,+bmi2 test.ll -o -
        .text
        .file   "test.ll"
        .globl  bzhi32_d2_load          # -- Begin function bzhi32_d2_load
        .p2align        4, 0x90
        .type   bzhi32_d2_load, at function
bzhi32_d2_load:                         # @bzhi32_d2_load
# %bb.0:
        movl    8(%esp), %eax
        movl    4(%esp), %ecx
        bzhil   %eax, (%ecx), %eax
        retl
.Lfunc_end0:
        .size   bzhi32_d2_load, .Lfunc_end0-bzhi32_d2_load
                                        # -- End function

        .section        ".note.GNU-stack","", at progbits
$ cat test.ll 
define i32 @bzhi32_d2_load(i32* %w, i32 %numlowbits) nounwind {
  %val = load i32, i32* %w
  %numhighbits = sub i32 32, %numlowbits
  %highbitscleared = shl i32 %val, %numhighbits
  %masked = lshr i32 %highbitscleared, %numhighbits
  ret i32 %masked
}
```



Repository:
  rL LLVM

https://reviews.llvm.org/D53521





More information about the llvm-commits mailing list