Test Failure: Transforms/InstCombine/select-cmp-cttz-ctlz.ll

Test source: git

Log:

Source: <stdin>

----------------------------------------
define i16 @test1(i16 %x) {
%0:
  %ct = ctlz i16 %x, 1
  %tobool = icmp ne i16 %x, 0
  %cond = select i1 %tobool, i16 %ct, i16 16
  ret i16 %cond
}
=>
define i16 @test1(i16 %x) {
%0:
  %ct = ctlz i16 %x, 0
  %range_l#0%ct = icmp sge i16 %ct, 0
  %range_h#0%ct = icmp slt i16 %ct, 17
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  ret i16 %ct
}
Transformation seems to be correct!


----------------------------------------
define i32 @test2(i32 %x) {
%0:
  %ct = ctlz i32 %x, 1
  %tobool = icmp ne i32 %x, 0
  %cond = select i1 %tobool, i32 %ct, i32 32
  ret i32 %cond
}
=>
define i32 @test2(i32 %x) {
%0:
  %ct = ctlz i32 %x, 0
  %range_l#0%ct = icmp sge i32 %ct, 0
  %range_h#0%ct = icmp slt i32 %ct, 33
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  ret i32 %ct
}
Transformation seems to be correct!


----------------------------------------
define i64 @test3(i64 %x) {
%0:
  %ct = ctlz i64 %x, 1
  %tobool = icmp ne i64 %x, 0
  %cond = select i1 %tobool, i64 %ct, i64 64
  ret i64 %cond
}
=>
define i64 @test3(i64 %x) {
%0:
  %ct = ctlz i64 %x, 0
  %range_l#0%ct = icmp sge i64 %ct, 0
  %range_h#0%ct = icmp slt i64 %ct, 65
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  ret i64 %ct
}
Transformation seems to be correct!


----------------------------------------
define i16 @test4(i16 %x) {
%0:
  %ct = ctlz i16 %x, 1
  %tobool = icmp eq i16 %x, 0
  %cond = select i1 %tobool, i16 16, i16 %ct
  ret i16 %cond
}
=>
define i16 @test4(i16 %x) {
%0:
  %ct = ctlz i16 %x, 0
  %range_l#0%ct = icmp sge i16 %ct, 0
  %range_h#0%ct = icmp slt i16 %ct, 17
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  ret i16 %ct
}
Transformation seems to be correct!


----------------------------------------
define i32 @test5(i32 %x) {
%0:
  %ct = ctlz i32 %x, 1
  %tobool = icmp eq i32 %x, 0
  %cond = select i1 %tobool, i32 32, i32 %ct
  ret i32 %cond
}
=>
define i32 @test5(i32 %x) {
%0:
  %ct = ctlz i32 %x, 0
  %range_l#0%ct = icmp sge i32 %ct, 0
  %range_h#0%ct = icmp slt i32 %ct, 33
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  ret i32 %ct
}
Transformation seems to be correct!


----------------------------------------
define i64 @test6(i64 %x) {
%0:
  %ct = ctlz i64 %x, 1
  %tobool = icmp eq i64 %x, 0
  %cond = select i1 %tobool, i64 64, i64 %ct
  ret i64 %cond
}
=>
define i64 @test6(i64 %x) {
%0:
  %ct = ctlz i64 %x, 0
  %range_l#0%ct = icmp sge i64 %ct, 0
  %range_h#0%ct = icmp slt i64 %ct, 65
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  ret i64 %ct
}
Transformation seems to be correct!


----------------------------------------
define i16 @test1b(i16 %x) {
%0:
  %ct = cttz i16 %x, 1
  %tobool = icmp ne i16 %x, 0
  %cond = select i1 %tobool, i16 %ct, i16 16
  ret i16 %cond
}
=>
define i16 @test1b(i16 %x) {
%0:
  %ct = cttz i16 %x, 0
  %range_l#0%ct = icmp sge i16 %ct, 0
  %range_h#0%ct = icmp slt i16 %ct, 17
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  ret i16 %ct
}
Transformation seems to be correct!


----------------------------------------
define i32 @test2b(i32 %x) {
%0:
  %ct = cttz i32 %x, 1
  %tobool = icmp ne i32 %x, 0
  %cond = select i1 %tobool, i32 %ct, i32 32
  ret i32 %cond
}
=>
define i32 @test2b(i32 %x) {
%0:
  %ct = cttz i32 %x, 0
  %range_l#0%ct = icmp sge i32 %ct, 0
  %range_h#0%ct = icmp slt i32 %ct, 33
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  ret i32 %ct
}
Transformation seems to be correct!


----------------------------------------
define i64 @test3b(i64 %x) {
%0:
  %ct = cttz i64 %x, 1
  %tobool = icmp ne i64 %x, 0
  %cond = select i1 %tobool, i64 %ct, i64 64
  ret i64 %cond
}
=>
define i64 @test3b(i64 %x) {
%0:
  %ct = cttz i64 %x, 0
  %range_l#0%ct = icmp sge i64 %ct, 0
  %range_h#0%ct = icmp slt i64 %ct, 65
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  ret i64 %ct
}
Transformation seems to be correct!


----------------------------------------
define i16 @test4b(i16 %x) {
%0:
  %ct = cttz i16 %x, 1
  %tobool = icmp eq i16 %x, 0
  %cond = select i1 %tobool, i16 16, i16 %ct
  ret i16 %cond
}
=>
define i16 @test4b(i16 %x) {
%0:
  %ct = cttz i16 %x, 0
  %range_l#0%ct = icmp sge i16 %ct, 0
  %range_h#0%ct = icmp slt i16 %ct, 17
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  ret i16 %ct
}
Transformation seems to be correct!


----------------------------------------
define i32 @test5b(i32 %x) {
%entry:
  %ct = cttz i32 %x, 1
  %tobool = icmp eq i32 %x, 0
  %cond = select i1 %tobool, i32 32, i32 %ct
  ret i32 %cond
}
=>
define i32 @test5b(i32 %x) {
%entry:
  %ct = cttz i32 %x, 0
  %range_l#0%ct = icmp sge i32 %ct, 0
  %range_h#0%ct = icmp slt i32 %ct, 33
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  ret i32 %ct
}
Transformation seems to be correct!


----------------------------------------
define i64 @test6b(i64 %x) {
%0:
  %ct = cttz i64 %x, 1
  %tobool = icmp eq i64 %x, 0
  %cond = select i1 %tobool, i64 64, i64 %ct
  ret i64 %cond
}
=>
define i64 @test6b(i64 %x) {
%0:
  %ct = cttz i64 %x, 0
  %range_l#0%ct = icmp sge i64 %ct, 0
  %range_h#0%ct = icmp slt i64 %ct, 65
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  ret i64 %ct
}
Transformation seems to be correct!


----------------------------------------
define i32 @test1c(i16 %x) {
%0:
  %ct = cttz i16 %x, 1
  %cast2 = zext i16 %ct to i32
  %tobool = icmp ne i16 %x, 0
  %cond = select i1 %tobool, i32 %cast2, i32 16
  ret i32 %cond
}
=>
define i32 @test1c(i16 %x) {
%0:
  %ct = cttz i16 %x, 0
  %range_l#0%ct = icmp sge i16 %ct, 0
  %range_h#0%ct = icmp slt i16 %ct, 17
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %cast2 = zext i16 %ct to i32
  ret i32 %cast2
}
Transformation seems to be correct!


----------------------------------------
define i64 @test2c(i16 %x) {
%0:
  %ct = cttz i16 %x, 1
  %conv = zext i16 %ct to i64
  %tobool = icmp ne i16 %x, 0
  %cond = select i1 %tobool, i64 %conv, i64 16
  ret i64 %cond
}
=>
define i64 @test2c(i16 %x) {
%0:
  %ct = cttz i16 %x, 0
  %range_l#0%ct = icmp sge i16 %ct, 0
  %range_h#0%ct = icmp slt i16 %ct, 17
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %conv = zext i16 %ct to i64
  ret i64 %conv
}
Transformation seems to be correct!


----------------------------------------
define i64 @test3c(i32 %x) {
%0:
  %ct = cttz i32 %x, 1
  %conv = zext i32 %ct to i64
  %tobool = icmp ne i32 %x, 0
  %cond = select i1 %tobool, i64 %conv, i64 32
  ret i64 %cond
}
=>
define i64 @test3c(i32 %x) {
%0:
  %ct = cttz i32 %x, 0
  %range_l#0%ct = icmp sge i32 %ct, 0
  %range_h#0%ct = icmp slt i32 %ct, 33
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %conv = zext i32 %ct to i64
  ret i64 %conv
}
Transformation seems to be correct!


----------------------------------------
define i32 @test4c(i16 %x) {
%0:
  %ct = ctlz i16 %x, 1
  %cast = zext i16 %ct to i32
  %tobool = icmp ne i16 %x, 0
  %cond = select i1 %tobool, i32 %cast, i32 16
  ret i32 %cond
}
=>
define i32 @test4c(i16 %x) {
%0:
  %ct = ctlz i16 %x, 0
  %range_l#0%ct = icmp sge i16 %ct, 0
  %range_h#0%ct = icmp slt i16 %ct, 17
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %cast = zext i16 %ct to i32
  ret i32 %cast
}
Transformation seems to be correct!


----------------------------------------
define i64 @test5c(i16 %x) {
%0:
  %ct = ctlz i16 %x, 1
  %cast = zext i16 %ct to i64
  %tobool = icmp ne i16 %x, 0
  %cond = select i1 %tobool, i64 %cast, i64 16
  ret i64 %cond
}
=>
define i64 @test5c(i16 %x) {
%0:
  %ct = ctlz i16 %x, 0
  %range_l#0%ct = icmp sge i16 %ct, 0
  %range_h#0%ct = icmp slt i16 %ct, 17
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %cast = zext i16 %ct to i64
  ret i64 %cast
}
Transformation seems to be correct!


----------------------------------------
define i64 @test6c(i32 %x) {
%0:
  %ct = ctlz i32 %x, 1
  %cast = zext i32 %ct to i64
  %tobool = icmp ne i32 %x, 0
  %cond = select i1 %tobool, i64 %cast, i64 32
  ret i64 %cond
}
=>
define i64 @test6c(i32 %x) {
%0:
  %ct = ctlz i32 %x, 0
  %range_l#0%ct = icmp sge i32 %ct, 0
  %range_h#0%ct = icmp slt i32 %ct, 33
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %cast = zext i32 %ct to i64
  ret i64 %cast
}
Transformation seems to be correct!


----------------------------------------
define i16 @test1d(i64 %x) {
%0:
  %ct = cttz i64 %x, 1
  %conv = trunc i64 %ct to i16
  %tobool = icmp ne i64 %x, 0
  %cond = select i1 %tobool, i16 %conv, i16 64
  ret i16 %cond
}
=>
define i16 @test1d(i64 %x) {
%0:
  %ct = cttz i64 %x, 0
  %range_l#0%ct = icmp sge i64 %ct, 0
  %range_h#0%ct = icmp slt i64 %ct, 65
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %conv = trunc i64 %ct to i16
  ret i16 %conv
}
Transformation seems to be correct!


----------------------------------------
define i32 @test2d(i64 %x) {
%0:
  %ct = cttz i64 %x, 1
  %cast = trunc i64 %ct to i32
  %tobool = icmp ne i64 %x, 0
  %cond = select i1 %tobool, i32 %cast, i32 64
  ret i32 %cond
}
=>
define i32 @test2d(i64 %x) {
%0:
  %ct = cttz i64 %x, 0
  %range_l#0%ct = icmp sge i64 %ct, 0
  %range_h#0%ct = icmp slt i64 %ct, 65
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %cast = trunc i64 %ct to i32
  ret i32 %cast
}
Transformation seems to be correct!


----------------------------------------
define i16 @test3d(i32 %x) {
%0:
  %ct = cttz i32 %x, 1
  %cast = trunc i32 %ct to i16
  %tobool = icmp ne i32 %x, 0
  %cond = select i1 %tobool, i16 %cast, i16 32
  ret i16 %cond
}
=>
define i16 @test3d(i32 %x) {
%0:
  %ct = cttz i32 %x, 0
  %range_l#0%ct = icmp sge i32 %ct, 0
  %range_h#0%ct = icmp slt i32 %ct, 33
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %cast = trunc i32 %ct to i16
  ret i16 %cast
}
Transformation seems to be correct!


----------------------------------------
define i16 @test4d(i64 %x) {
%0:
  %ct = ctlz i64 %x, 1
  %cast = trunc i64 %ct to i16
  %tobool = icmp ne i64 %x, 0
  %cond = select i1 %tobool, i16 %cast, i16 64
  ret i16 %cond
}
=>
define i16 @test4d(i64 %x) {
%0:
  %ct = ctlz i64 %x, 0
  %range_l#0%ct = icmp sge i64 %ct, 0
  %range_h#0%ct = icmp slt i64 %ct, 65
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %cast = trunc i64 %ct to i16
  ret i16 %cast
}
Transformation seems to be correct!


----------------------------------------
define i32 @test5d(i64 %x) {
%0:
  %ct = ctlz i64 %x, 1
  %cast = trunc i64 %ct to i32
  %tobool = icmp ne i64 %x, 0
  %cond = select i1 %tobool, i32 %cast, i32 64
  ret i32 %cond
}
=>
define i32 @test5d(i64 %x) {
%0:
  %ct = ctlz i64 %x, 0
  %range_l#0%ct = icmp sge i64 %ct, 0
  %range_h#0%ct = icmp slt i64 %ct, 65
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %cast = trunc i64 %ct to i32
  ret i32 %cast
}
Transformation seems to be correct!


----------------------------------------
define i16 @test6d(i32 %x) {
%0:
  %ct = ctlz i32 %x, 1
  %cast = trunc i32 %ct to i16
  %tobool = icmp ne i32 %x, 0
  %cond = select i1 %tobool, i16 %cast, i16 32
  ret i16 %cond
}
=>
define i16 @test6d(i32 %x) {
%0:
  %ct = ctlz i32 %x, 0
  %range_l#0%ct = icmp sge i32 %ct, 0
  %range_h#0%ct = icmp slt i32 %ct, 33
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %cast = trunc i32 %ct to i16
  ret i16 %cast
}
Transformation seems to be correct!


----------------------------------------
define i64 @select_bug1(i32 %x) {
%0:
  %ct = cttz i32 %x, 0
  %conv = zext i32 %ct to i64
  %tobool = icmp ne i32 %x, 0
  %cond = select i1 %tobool, i64 %conv, i64 32
  ret i64 %cond
}
=>
define i64 @select_bug1(i32 %x) {
%0:
  %ct = cttz i32 %x, 0
  %range_l#0%ct = icmp sge i32 %ct, 0
  %range_h#0%ct = icmp slt i32 %ct, 33
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %conv = zext i32 %ct to i64
  ret i64 %conv
}
Transformation seems to be correct!


----------------------------------------
define i16 @select_bug2(i32 %x) {
%0:
  %ct = cttz i32 %x, 0
  %conv = trunc i32 %ct to i16
  %tobool = icmp ne i32 %x, 0
  %cond = select i1 %tobool, i16 %conv, i16 32
  ret i16 %cond
}
=>
define i16 @select_bug2(i32 %x) {
%0:
  %ct = cttz i32 %x, 0
  %range_l#0%ct = icmp sge i32 %ct, 0
  %range_h#0%ct = icmp slt i32 %ct, 33
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %conv = trunc i32 %ct to i16
  ret i16 %conv
}
Transformation seems to be correct!


----------------------------------------
define i128 @test7(i128 %x) {
%0:
  %ct = ctlz i128 %x, 1
  %tobool = icmp ne i128 %x, 0
  %cond = select i1 %tobool, i128 %ct, i128 128
  ret i128 %cond
}
=>
define i128 @test7(i128 %x) {
%0:
  %ct = ctlz i128 %x, 0
  %range_l#0%ct = icmp sge i128 %ct, 0
  %range_h#0%ct = icmp slt i128 %ct, 129
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  ret i128 %ct
}
Transformation seems to be correct!


----------------------------------------
define i128 @test8(i128 %x) {
%0:
  %ct = cttz i128 %x, 1
  %tobool = icmp ne i128 %x, 0
  %cond = select i1 %tobool, i128 %ct, i128 128
  ret i128 %cond
}
=>
define i128 @test8(i128 %x) {
%0:
  %ct = cttz i128 %x, 0
  %range_l#0%ct = icmp sge i128 %ct, 0
  %range_h#0%ct = icmp slt i128 %ct, 129
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  ret i128 %ct
}
Transformation seems to be correct!


----------------------------------------
define i32 @test_ctlz_not_bw(i32 %x) {
%0:
  %ct = ctlz i32 %x, 0
  %cmp = icmp ne i32 %x, 0
  %res = select i1 %cmp, i32 %ct, i32 123
  ret i32 %res
}
=>
define i32 @test_ctlz_not_bw(i32 %x) {
%0:
  %ct = ctlz i32 %x, 1
  %range_l#0%ct = icmp sge i32 %ct, 0
  %range_h#0%ct = icmp slt i32 %ct, 33
  %range#0%ct = and i1 %range_l#0%ct, %range_h#0%ct
  assume_non_poison i1 %range#0%ct
  %cmp = icmp eq i32 %x, 0
  %res = select i1 %cmp, i32 123, i32 %ct
  ret i32 %res
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source

Example:
i32 %x = undef

Source:
i32 %ct = #x00000020 (32)	[based on undef value]
i1 %cmp = undef
i32 %res = #x0000007b (123)	[based on undef value]

Target:
i32 %ct = #x00000000 (0)
i1 %range_l#0%ct = #x1 (1)
i1 %range_h#0%ct = #x1 (1)
i1 %range#0%ct = #x1 (1)
i1 %cmp = #x0 (0)
i32 %res = poison
Source value: #x0000007b (123)
Target value: poison


------------------- SMT STATS -------------------
Num queries: 90
Num invalid: 0
Num skips:   0
Num trivial: 56 (38.4%)
Num timeout: 0 (0.0%)
Num errors:  0 (0.0%)
Num SAT:     32 (35.6%)
Num UNSAT:   58 (64.4%)

stderr:

+ : 'RUN: at line 2'
+ /home/nlopes/alive2/scripts/opt-alive.sh -instcombine -S
+ /home/nlopes/llvm/build/bin/FileCheck /home/nlopes/llvm/llvm/test/Transforms/InstCombine/select-cmp-cttz-ctlz.ll

Alive2: Transform doesn't verify; aborting!
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/nlopes/llvm/build/bin/FileCheck /home/nlopes/llvm/llvm/test/Transforms/InstCombine/select-cmp-cttz-ctlz.ll

 

NOTE: This test would pass if undef didn't exist!

 

<-- Back