[PATCH] Remove redundant folding of bswap(bswap(x))

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Aug 13 10:53:56 PDT 2014


>      // bswap(trunc(bswap(x))) -> trunc(lshr(x, c))
>      if (match(IIOperand, m_Trunc(m_BSwap(m_Value(X))))) {
>        unsigned C = X->getType()->getPrimitiveSizeInBits() -
> Index: test/Transforms/InstSimplify/call.ll
> ===================================================================
> --- test/Transforms/InstSimplify/call.ll
> +++ test/Transforms/InstSimplify/call.ll
> @@ -102,6 +102,17 @@
>    ret float %r4
>  }
>
> +declare i32 @llvm.bswap.i32(i32) nounwind readnone
> +
> +; CHECK-LABEL: @test_idempotence_2(
> +; CHECK: bswap

What does this match? Didn't we remove the bswap?

In general, it is probably better to match the code that is generated
in a bit more detail. In particular, this function is so small that
you should be able to just use a few CHECK-NEXT until the ret.

> +; CHECK-NOT: bswap
> +define i32 @test_idempotence_2(i32 %a) {
> +  %a0 = call i32 @llvm.bswap.i32(i32 %a)
> +  %a1 = call i32 @llvm.bswap.i32(i32 %a0)
> +  ret i32 %a1
> +}
> +



More information about the llvm-commits mailing list