diff options
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/Transforms/InstCombine/select.ll | 27 | ||||
-rw-r--r-- | llvm/test/Transforms/InstSimplify/select.ll | 3 |
2 files changed, 29 insertions, 1 deletions
diff --git a/llvm/test/Transforms/InstCombine/select.ll b/llvm/test/Transforms/InstCombine/select.ll index f8c96e7f3f6..f8fe2fbc1a2 100644 --- a/llvm/test/Transforms/InstCombine/select.ll +++ b/llvm/test/Transforms/InstCombine/select.ll @@ -1332,3 +1332,30 @@ define <4 x i32> @cannot_canonicalize_to_shuffle2(<4 x i32> %a, <4 x i32> %b) { ret <4 x i32> %sel } +declare void @llvm.assume(i1) + +define i8 @assume_cond_true(i1 %cond, i8 %x, i8 %y) { +; CHECK-LABEL: @assume_cond_true( +; CHECK-NEXT: call void @llvm.assume(i1 %cond) +; CHECK-NEXT: ret i8 %x +; + call void @llvm.assume(i1 %cond) + %sel = select i1 %cond, i8 %x, i8 %y + ret i8 %sel +} + +; FIXME: computeKnownBitsFromAssume() should understand the 'not' of an assumed condition. + +define i8 @assume_cond_false(i1 %cond, i8 %x, i8 %y) { +; CHECK-LABEL: @assume_cond_false( +; CHECK-NEXT: [[NOTCOND:%.*]] = xor i1 %cond, true +; CHECK-NEXT: call void @llvm.assume(i1 [[NOTCOND]]) +; CHECK-NEXT: [[SEL:%.*]] = select i1 %cond, i8 %x, i8 %y +; CHECK-NEXT: ret i8 [[SEL]] +; + %notcond = xor i1 %cond, true + call void @llvm.assume(i1 %notcond) + %sel = select i1 %cond, i8 %x, i8 %y + ret i8 %sel +} + diff --git a/llvm/test/Transforms/InstSimplify/select.ll b/llvm/test/Transforms/InstSimplify/select.ll index 1acb5c469d3..cb2502cf63c 100644 --- a/llvm/test/Transforms/InstSimplify/select.ll +++ b/llvm/test/Transforms/InstSimplify/select.ll @@ -402,7 +402,8 @@ define i32* @select_icmp_pointers(i32* %x, i32* %y) { ret i32* %sel } -; FIXME: If the condition is known, we don't need to select. +; If the condition is known, we don't need to select, but we're not +; doing this fold here to avoid compile-time cost. declare void @llvm.assume(i1) |