Idempotent intrinsics are already generally handled, so no need to special case bswap.
Details
Details
- Reviewers
- None
Diff Detail
Diff Detail
Event Timeline
Comment Actions
// 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
+}
+
Comment Actions
This is just a thinko. I was misreading this as bswap(bswap(x)) -> bswap(x), but it actually removes the bswap which makes more sense