aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2024-06-04 15:42:25 +0200
committerNikita Popov <npopov@redhat.com>2024-06-04 15:48:08 +0200
commit11725b5240840e077c944af6a56e75dd00275395 (patch)
treee1eb63268b0716f6e99f04391e3a68f455da4ecf /llvm
parente651ee98cfcdebd799de0d61eca22b7b1493cc96 (diff)
downloadllvm-11725b5240840e077c944af6a56e75dd00275395.zip
llvm-11725b5240840e077c944af6a56e75dd00275395.tar.gz
llvm-11725b5240840e077c944af6a56e75dd00275395.tar.bz2
[InstCombine] Add tests for incorrect range handling in ctz fold (NFC)
Diffstat (limited to 'llvm')
-rw-r--r--llvm/test/Transforms/InstCombine/select-cmp-cttz-ctlz.ll24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/select-cmp-cttz-ctlz.ll b/llvm/test/Transforms/InstCombine/select-cmp-cttz-ctlz.ll
index 3d5f2c2..eac4685 100644
--- a/llvm/test/Transforms/InstCombine/select-cmp-cttz-ctlz.ll
+++ b/llvm/test/Transforms/InstCombine/select-cmp-cttz-ctlz.ll
@@ -49,6 +49,18 @@ define i16 @test4(i16 %x) {
ret i16 %cond
}
+; FIXME: This is a miscompile.
+define i16 @test4_with_range(i16 %x) {
+; CHECK-LABEL: @test4_with_range(
+; CHECK-NEXT: [[CT:%.*]] = call range(i16 0, 16) i16 @llvm.ctlz.i16(i16 [[X:%.*]], i1 false)
+; CHECK-NEXT: ret i16 [[CT]]
+;
+ %ct = call range(i16 0, 16) i16 @llvm.ctlz.i16(i16 %x, i1 true)
+ %tobool = icmp eq i16 %x, 0
+ %cond = select i1 %tobool, i16 16, i16 %ct
+ ret i16 %cond
+}
+
define i32 @test5(i32 %x) {
; CHECK-LABEL: @test5(
; CHECK-NEXT: [[CT:%.*]] = tail call range(i32 0, 33) i32 @llvm.ctlz.i32(i32 [[X:%.*]], i1 false)
@@ -115,6 +127,18 @@ define i16 @test4b(i16 %x) {
ret i16 %cond
}
+; FIXME: This is a miscompile.
+define i16 @test4b_with_range(i16 %x) {
+; CHECK-LABEL: @test4b_with_range(
+; CHECK-NEXT: [[CT:%.*]] = call range(i16 0, 16) i16 @llvm.cttz.i16(i16 [[X:%.*]], i1 false)
+; CHECK-NEXT: ret i16 [[CT]]
+;
+ %ct = call range(i16 0, 16) i16 @llvm.cttz.i16(i16 %x, i1 true)
+ %tobool = icmp eq i16 %x, 0
+ %cond = select i1 %tobool, i16 16, i16 %ct
+ ret i16 %cond
+}
+
define i32 @test5b(i32 %x) {
; CHECK-LABEL: @test5b(
; CHECK-NEXT: entry: