Skip to content

Conversation

nickdesaulniers
Copy link
Member

Fixes the following from GCC:

llvm-project/libc/src/string/memory_utils/op_x86.h:236:24: error:
conversion from ‘long unsigned int’ to ‘uint32_t’ {aka ‘unsigned int’} may
change value [-Werror=conversion]
  236 |   return (xored >> 32) | (xored & 0xFFFFFFFF);
      |          ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

Link: https://lab.llvm.org/buildbot/#/builders/250/builds/16236/steps/8/logs/stdio
Link: #74506

Fixes the following from GCC:

    llvm-project/libc/src/string/memory_utils/op_x86.h:236:24: error:
    conversion from ‘long unsigned int’ to ‘uint32_t’ {aka ‘unsigned int’} may
    change value [-Werror=conversion]
      236 |   return (xored >> 32) | (xored & 0xFFFFFFFF);
          |          ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

Link: https://lab.llvm.org/buildbot/#/builders/250/builds/16236/steps/8/logs/stdio
Link: llvm#74506
@llvmbot llvmbot added the libc label Jan 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 8, 2024

@llvm/pr-subscribers-libc

Author: Nick Desaulniers (nickdesaulniers)

Changes

Fixes the following from GCC:

llvm-project/libc/src/string/memory_utils/op_x86.h:236:24: error:
conversion from ‘long unsigned int’ to ‘uint32_t’ {aka ‘unsigned int’} may
change value [-Werror=conversion]
  236 |   return (xored >> 32) | (xored & 0xFFFFFFFF);
      |          ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

Link: https://lab.llvm.org/buildbot/#/builders/250/builds/16236/steps/8/logs/stdio
Link: #74506


Full diff: https://github.com/llvm/llvm-project/pull/77384.diff

1 Files Affected:

  • (modified) libc/src/string/memory_utils/op_x86.h (+2-1)
diff --git a/libc/src/string/memory_utils/op_x86.h b/libc/src/string/memory_utils/op_x86.h
index 1a20659c178cd1..3d2eb13fa302ad 100644
--- a/libc/src/string/memory_utils/op_x86.h
+++ b/libc/src/string/memory_utils/op_x86.h
@@ -233,7 +233,8 @@ template <> LIBC_INLINE uint32_t neq<__m512i>(CPtr p1, CPtr p2, size_t offset) {
   const auto a = load<__m512i>(p1, offset);
   const auto b = load<__m512i>(p2, offset);
   const uint64_t xored = _mm512_cmpneq_epi8_mask(a, b);
-  return (xored >> 32) | (xored & 0xFFFFFFFF);
+  return static_cast<uint32_t>(xored >> 32) |
+         static_cast<uint32_t>(xored & 0xFFFFFFFF));
 }
 template <>
 LIBC_INLINE MemcmpReturnType cmp_neq<__m512i>(CPtr p1, CPtr p2, size_t offset) {

@nickdesaulniers nickdesaulniers merged commit 6958986 into llvm:main Jan 9, 2024
@nickdesaulniers nickdesaulniers deleted the gcc_conversion branch January 9, 2024 00:08
const uint64_t xored = _mm512_cmpneq_epi8_mask(a, b);
return (xored >> 32) | (xored & 0xFFFFFFFF);
return static_cast<uint32_t>(xored >> 32) |
static_cast<uint32_t>(xored & 0xFFFFFFFF));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra )

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 1689bbe

nickdesaulniers added a commit that referenced this pull request Jan 9, 2024
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
Fixes the following from GCC:

    llvm-project/libc/src/string/memory_utils/op_x86.h:236:24: error:
conversion from ‘long unsigned int’ to ‘uint32_t’ {aka ‘unsigned int’}
may
    change value [-Werror=conversion]
      236 |   return (xored >> 32) | (xored & 0xFFFFFFFF);
          |          ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

Link:
https://lab.llvm.org/buildbot/#/builders/250/builds/16236/steps/8/logs/stdio
Link: llvm#74506
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants