小编Liq*_*iqs的帖子

测试 xmm 寄存器中的任何字节是否为 0

我目前正在自学 SIMD 并且正在编写一个相当简单的字符串处理子程序。然而,我仅限于 SSE2,这使我无法利用 ptest 找到空终端。

我目前试图找到空终端的方式使我的 SIMD 循环有 >16 条指令,这违背了使用 SIMD 的目的 - 或者至少使它不那么值得。

//Check for null byte
pxor xmm4, xmm4
pcmpeqb xmm4, [rdi]                                   //Generate bitmask
movq rax, xmm4
test rax, 0xffffffffffffffff                          //Test low qword
jnz .Lepilogue
movhlps xmm4, xmm4                                    //Move high into low qword
movq rax, xmm4
test rax, 0xffffffffffffffff                          //Test high qword
jz .LsimdLoop                                         //No terminal was found, keep looping
Run Code Online (Sandbox Code Playgroud)

我想知道在没有 ptest 的情况下是否有任何更快的方法可以做到这一点,或者这是否是最好的方法,我将不得不再优化循环的其余部分。

注意:我确保输入使用 SIMD 的循环的字符串地址是 16B 对齐的,以允许对齐的指令。

string x86 assembly simd sse2

3
推荐指数
1
解决办法
346
查看次数

即使指定了“match_parent”,使用 ConstraintLayout 的 RecyclerView 项目也不会填充屏幕的整个宽度

我正在尝试设置一个回收器视图,并使用 ConstraintLayout 显示元素。我使用Google 示例中的布局作为指导。

然而,尽管android:layout_width="match_parent"一路向下指定,最终显示在屏幕上的结果更类似于wrap_content.

到目前为止我已经尝试过的

  1. 将 ConstraintLayout更改为 LinearLayout
  2. stackoverflow 问题中建议的解决方法
  3. 设置android:layout_width=0,同时使用ConstraintLayout并将start、end 和 top 锚定到父级
  4. 将整个内容包装在 CardView 中
  5. 在多个设备(模拟设备和物理设备)上运行应用程序

相关代码

如果缺少任何其他感兴趣的内容,请告诉我。

食谱列表条目.xml

    <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="@dimen/recipe_entry_height" >

    <TextView
        android:id="@+id/recipe_title"
        style="@style/Widget.RecipeTracker.ListItemTextView"
        android:layout_marginHorizontal="@dimen/margin_between_elements"
        android:background="@color/design_default_color_on_secondary"
        android:layout_width="match_parent"
        android:fontFamily="sans-serif"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:maxLines="1"
        android:ellipsize="end"
        tools:text="amazing stuff"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

样式.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Widget.RecipeTracker.ListItemTextView" parent="Widget.MaterialComponents.TextView">
        <item name="android:gravity">center_vertical</item>
        <item name="android:layout_height">48dp</item>
        <item …
Run Code Online (Sandbox Code Playgroud)

android android-layout kotlin android-recyclerview android-constraintlayout

3
推荐指数
1
解决办法
3219
查看次数