diff options
| -rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 6 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstSimplify/call.ll | 8 |
2 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index d3b82d5..632741e 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -5485,6 +5485,12 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1, return Op0; break; + case Intrinsic::cttz: { + Value *X; + if (match(Op0, m_Shl(m_One(), m_Value(X)))) + return X; + break; + } case Intrinsic::smax: case Intrinsic::smin: case Intrinsic::umax: diff --git a/llvm/test/Transforms/InstSimplify/call.ll b/llvm/test/Transforms/InstSimplify/call.ll index c89f0048..5b4acb5 100644 --- a/llvm/test/Transforms/InstSimplify/call.ll +++ b/llvm/test/Transforms/InstSimplify/call.ll @@ -1365,9 +1365,7 @@ declare <3 x i33> @llvm.cttz.v3i33(<3 x i33>, i1) define i32 @cttz_shl1(i32 %x) { ; CHECK-LABEL: @cttz_shl1( -; CHECK-NEXT: [[S:%.*]] = shl i32 1, [[X:%.*]] -; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.cttz.i32(i32 [[S]], i1 true) -; CHECK-NEXT: ret i32 [[R]] +; CHECK-NEXT: ret i32 [[X:%.*]] ; %s = shl i32 1, %x %r = call i32 @llvm.cttz.i32(i32 %s, i1 true) @@ -1376,9 +1374,7 @@ define i32 @cttz_shl1(i32 %x) { define <3 x i33> @cttz_shl1_vec(<3 x i33> %x) { ; CHECK-LABEL: @cttz_shl1_vec( -; CHECK-NEXT: [[S:%.*]] = shl <3 x i33> <i33 1, i33 1, i33 undef>, [[X:%.*]] -; CHECK-NEXT: [[R:%.*]] = call <3 x i33> @llvm.cttz.v3i33(<3 x i33> [[S]], i1 false) -; CHECK-NEXT: ret <3 x i33> [[R]] +; CHECK-NEXT: ret <3 x i33> [[X:%.*]] ; %s = shl <3 x i33> <i33 1, i33 1, i33 undef>, %x %r = call <3 x i33> @llvm.cttz.v3i33(<3 x i33> %s, i1 false) |
