Test Failure: Transforms/InstCombine/bswap.ll

Test source: git

Log:

Source: <stdin>

----------------------------------------
define i32 @test1(i32 %i) {
%0:
  %t1 = lshr i32 %i, 24
  %t3 = lshr i32 %i, 8
  %t4 = and i32 %t3, 65280
  %t5 = or i32 %t1, %t4
  %t7 = shl i32 %i, 8
  %t8 = and i32 %t7, 16711680
  %t9 = or i32 %t5, %t8
  %t11 = shl i32 %i, 24
  %t12 = or i32 %t9, %t11
  ret i32 %t12
}
=>
define i32 @test1(i32 %i) {
%0:
  %t12 = bswap i32 %i
  ret i32 %t12
}
Transformation seems to be correct!


----------------------------------------
define <2 x i32> @test1_vector(<2 x i32> %i) {
%0:
  %t1 = lshr <2 x i32> %i, { 24, 24 }
  %t3 = lshr <2 x i32> %i, { 8, 8 }
  %t4 = and <2 x i32> %t3, { 65280, 65280 }
  %t5 = or <2 x i32> %t1, %t4
  %t7 = shl <2 x i32> %i, { 8, 8 }
  %t8 = and <2 x i32> %t7, { 16711680, 16711680 }
  %t9 = or <2 x i32> %t5, %t8
  %t11 = shl <2 x i32> %i, { 24, 24 }
  %t12 = or <2 x i32> %t9, %t11
  ret <2 x i32> %t12
}
=>
define <2 x i32> @test1_vector(<2 x i32> %i) {
%0:
  %t12 = bswap <2 x i32> %i
  ret <2 x i32> %t12
}
Transformation doesn't verify!
ERROR: Timeout


----------------------------------------
define i16 @test1_trunc(i32 %i) {
%0:
  %t1 = lshr i32 %i, 24
  %t3 = lshr i32 %i, 8
  %t4 = and i32 %t3, 65280
  %t5 = or i32 %t1, %t4
  %t13 = trunc i32 %t5 to i16
  ret i16 %t13
}
=>
define i16 @test1_trunc(i32 %i) {
%0:
  %t1 = lshr i32 %i, 24
  %t3 = lshr i32 %i, 8
  %t4 = and i32 %t3, 65280
  %t5 = or i32 %t1, %t4
  %t13 = trunc i32 %t5 to i16
  ret i16 %t13
}
Transformation seems to be correct! (syntactically equal)


----------------------------------------
define i16 @test1_trunc_extra_use(i32 %i) {
%0:
  %t1 = lshr i32 %i, 24
  %t3 = lshr i32 %i, 8
  %t4 = and i32 %t3, 65280
  %t5 = or i32 %t1, %t4
  call void @extra_use(i32 %t5)
  %t13 = trunc i32 %t5 to i16
  ret i16 %t13
}
=>
define i16 @test1_trunc_extra_use(i32 %i) {
%0:
  %t1 = lshr i32 %i, 24
  %t3 = lshr i32 %i, 8
  %t4 = and i32 %t3, 65280
  %t5 = or i32 %t1, %t4
  call void @extra_use(i32 %t5)
  %t13 = trunc i32 %t5 to i16
  ret i16 %t13
}
Transformation seems to be correct! (syntactically equal)


----------------------------------------
define i32 @test2(i32 %arg) {
%0:
  %t2 = shl i32 %arg, 24
  %t4 = shl i32 %arg, 8
  %t5 = and i32 %t4, 16711680
  %t6 = or i32 %t2, %t5
  %t8 = lshr i32 %arg, 8
  %t9 = and i32 %t8, 65280
  %t10 = or i32 %t6, %t9
  %t12 = lshr i32 %arg, 24
  %t14 = or i32 %t10, %t12
  ret i32 %t14
}
=>
define i32 @test2(i32 %arg) {
%0:
  %t14 = bswap i32 %arg
  ret i32 %t14
}
Transformation seems to be correct!


----------------------------------------
define <2 x i32> @test2_vector(<2 x i32> %arg) {
%0:
  %t2 = shl <2 x i32> %arg, { 24, 24 }
  %t4 = shl <2 x i32> %arg, { 8, 8 }
  %t5 = and <2 x i32> %t4, { 16711680, 16711680 }
  %t6 = or <2 x i32> %t2, %t5
  %t8 = lshr <2 x i32> %arg, { 8, 8 }
  %t9 = and <2 x i32> %t8, { 65280, 65280 }
  %t10 = or <2 x i32> %t6, %t9
  %t12 = lshr <2 x i32> %arg, { 24, 24 }
  %t14 = or <2 x i32> %t10, %t12
  ret <2 x i32> %t14
}
=>
define <2 x i32> @test2_vector(<2 x i32> %arg) {
%0:
  %t14 = bswap <2 x i32> %arg
  ret <2 x i32> %t14
}
Transformation doesn't verify!
ERROR: Timeout


----------------------------------------
define <2 x i32> @test2_vector_undef(<2 x i32> %arg) {
%0:
  %t2 = shl <2 x i32> %arg, { 24, undef }
  %t4 = shl <2 x i32> %arg, { 8, 8 }
  %t5 = and <2 x i32> %t4, { 16711680, undef }
  %t6 = or <2 x i32> %t2, %t5
  %t8 = lshr <2 x i32> %arg, { 8, 8 }
  %t9 = and <2 x i32> %t8, { 65280, undef }
  %t10 = or <2 x i32> %t6, %t9
  %t12 = lshr <2 x i32> %arg, { 24, undef }
  %t14 = or <2 x i32> %t10, %t12
  ret <2 x i32> %t14
}
=>
define <2 x i32> @test2_vector_undef(<2 x i32> %arg) {
%0:
  %t2 = shl <2 x i32> %arg, { 24, undef }
  %t4 = shl <2 x i32> %arg, { 8, 8 }
  %t5 = and <2 x i32> %t4, { 16711680, undef }
  %t6 = or <2 x i32> %t2, %t5
  %t8 = lshr <2 x i32> %arg, { 8, 8 }
  %t9 = and <2 x i32> %t8, { 65280, undef }
  %t10 = or <2 x i32> %t6, %t9
  %t12 = lshr <2 x i32> %arg, { 24, undef }
  %t14 = or <2 x i32> %t10, %t12
  ret <2 x i32> %t14
}
Transformation seems to be correct! (syntactically equal)


----------------------------------------
define i16 @test3(i16 %s) {
%0:
  %t2 = lshr i16 %s, 8
  %t4 = shl i16 %s, 8
  %t5 = or i16 %t2, %t4
  ret i16 %t5
}
=>
define i16 @test3(i16 %s) {
%0:
  %t5 = bswap i16 %s
  ret i16 %t5
}
Transformation seems to be correct!


----------------------------------------
define <2 x i16> @test3_vector(<2 x i16> %s) {
%0:
  %t2 = lshr <2 x i16> %s, { 8, 8 }
  %t4 = shl <2 x i16> %s, { 8, 8 }
  %t5 = or <2 x i16> %t2, %t4
  ret <2 x i16> %t5
}
=>
define <2 x i16> @test3_vector(<2 x i16> %s) {
%0:
  %t5 = bswap <2 x i16> %s
  ret <2 x i16> %t5
}
Transformation doesn't verify!
ERROR: Timeout


----------------------------------------
define <2 x i16> @test3_vector_undef(<2 x i16> %s) {
%0:
  %t2 = lshr <2 x i16> %s, { undef, 8 }
  %t4 = shl <2 x i16> %s, { 8, undef }
  %t5 = or <2 x i16> %t2, %t4
  ret <2 x i16> %t5
}
=>
define <2 x i16> @test3_vector_undef(<2 x i16> %s) {
%0:
  %t5 = bswap <2 x i16> %s
  ret <2 x i16> %t5
}
Transformation seems to be correct!


----------------------------------------
define i16 @test4(i16 %s) {
%0:
  %t2 = lshr i16 %s, 8
  %t4 = shl i16 %s, 8
  %t5 = or i16 %t4, %t2
  ret i16 %t5
}
=>
define i16 @test4(i16 %s) {
%0:
  %t5 = bswap i16 %s
  ret i16 %t5
}
Transformation seems to be correct!


----------------------------------------
define <2 x i16> @test4_vector(<2 x i16> %s) {
%0:
  %t2 = lshr <2 x i16> %s, { 8, 8 }
  %t4 = shl <2 x i16> %s, { 8, 8 }
  %t5 = or <2 x i16> %t4, %t2
  ret <2 x i16> %t5
}
=>
define <2 x i16> @test4_vector(<2 x i16> %s) {
%0:
  %t5 = bswap <2 x i16> %s
  ret <2 x i16> %t5
}
Transformation doesn't verify!
ERROR: Timeout


----------------------------------------
define i16 @test5(i16 %a) {
%0:
  %t = zext i16 %a to i32
  %t1 = and i32 %t, 65280
  %t2 = ashr i32 %t1, 8
  %t2.upgrd.1 = trunc i32 %t2 to i16
  %t4 = and i32 %t, 255
  %t5 = shl i32 %t4, 8
  %t5.upgrd.2 = trunc i32 %t5 to i16
  %t.upgrd.3 = or i16 %t2.upgrd.1, %t5.upgrd.2
  %t6 = bitcast i16 %t.upgrd.3 to i16
  %t6.upgrd.4 = zext i16 %t6 to i32
  %retval = trunc i32 %t6.upgrd.4 to i16
  ret i16 %retval
}
=>
define i16 @test5(i16 %a) {
%0:
  %t.upgrd.3 = bswap i16 %a
  ret i16 %t.upgrd.3
}
Transformation doesn't verify!
ERROR: Timeout


----------------------------------------
define <2 x i16> @test5_vector(<2 x i16> %a) {
%0:
  %t = zext <2 x i16> %a to <2 x i32>
  %t1 = and <2 x i32> %t, { 65280, 65280 }
  %t2 = ashr <2 x i32> %t1, { 8, 8 }
  %t2.upgrd.1 = trunc <2 x i32> %t2 to <2 x i16>
  %t4 = and <2 x i32> %t, { 255, 255 }
  %t5 = shl <2 x i32> %t4, { 8, 8 }
  %t5.upgrd.2 = trunc <2 x i32> %t5 to <2 x i16>
  %t.upgrd.3 = or <2 x i16> %t2.upgrd.1, %t5.upgrd.2
  %t6 = bitcast <2 x i16> %t.upgrd.3 to <2 x i16>
  %t6.upgrd.4 = zext <2 x i16> %t6 to <2 x i32>
  %retval = trunc <2 x i32> %t6.upgrd.4 to <2 x i16>
  ret <2 x i16> %retval
}
=>
define <2 x i16> @test5_vector(<2 x i16> %a) {
%0:
  %t.upgrd.3 = bswap <2 x i16> %a
  ret <2 x i16> %t.upgrd.3
}
Transformation doesn't verify!
ERROR: Timeout


----------------------------------------
define i32 @test6(i32 %x) noread nowrite nofree {
%0:
  %t = shl i32 %x, 16
  %x.mask = and i32 %x, 65280
  %t1 = lshr i32 %x, 16
  %t2 = and i32 %t1, 255
  %t3 = or i32 %x.mask, %t
  %t4 = or i32 %t3, %t2
  %t5 = shl i32 %t4, 8
  %t6 = lshr i32 %x, 24
  %t7 = or i32 %t5, %t6
  ret i32 %t7
}
=>
define i32 @test6(i32 %x) noread nowrite nofree {
%0:
  %t7 = bswap i32 %x
  ret i32 %t7
}
Transformation seems to be correct!


----------------------------------------
define <2 x i32> @test6_vector(<2 x i32> %x) noread nowrite nofree {
%0:
  %t = shl <2 x i32> %x, { 16, 16 }
  %x.mask = and <2 x i32> %x, { 65280, 65280 }
  %t1 = lshr <2 x i32> %x, { 16, 16 }
  %t2 = and <2 x i32> %t1, { 255, 255 }
  %t3 = or <2 x i32> %x.mask, %t
  %t4 = or <2 x i32> %t3, %t2
  %t5 = shl <2 x i32> %t4, { 8, 8 }
  %t6 = lshr <2 x i32> %x, { 24, 24 }
  %t7 = or <2 x i32> %t5, %t6
  ret <2 x i32> %t7
}
=>
define <2 x i32> @test6_vector(<2 x i32> %x) noread nowrite nofree {
%0:
  %t7 = bswap <2 x i32> %x
  ret <2 x i32> %t7
}
Transformation doesn't verify!
ERROR: Timeout


----------------------------------------
define i32 @bswap32_and_first(i32 %x) {
%0:
  %shl = shl i32 %x, 16
  %shr = lshr i32 %x, 16
  %swaphalf = or i32 %shl, %shr
  %t = and i32 %swaphalf, 16711935
  %tshl = shl nuw i32 %t, 8
  %b = lshr i32 %swaphalf, 8
  %band = and i32 %b, 16711935
  %bswap = or i32 %tshl, %band
  ret i32 %bswap
}
=>
define i32 @bswap32_and_first(i32 %x) {
%0:
  %bswap = bswap i32 %x
  ret i32 %bswap
}
Transformation seems to be correct!


----------------------------------------
define i32 @bswap32_and_first_extra_use(i32 %x) {
%0:
  %shl = shl i32 %x, 16
  %shr = lshr i32 %x, 16
  %swaphalf = or i32 %shl, %shr
  %t = and i32 %swaphalf, 16711935
  %tshl = shl nuw i32 %t, 8
  %b = lshr i32 %swaphalf, 8
  %band = and i32 %b, 16711935
  %bswap = or i32 %tshl, %band
  call void @extra_use(i32 %t)
  ret i32 %bswap
}
=>
define i32 @bswap32_and_first_extra_use(i32 %x) {
%0:
  %swaphalf = fshl i32 %x, i32 %x, i32 16
  %t = and i32 %swaphalf, 16711935
  %bswap = bswap i32 %x
  call void @extra_use(i32 %t)
  ret i32 %bswap
}
Transformation doesn't verify!
ERROR: Timeout


----------------------------------------
define i32 @bswap32_shl_first(i32 %x) {
%0:
  %shl = shl i32 %x, 16
  %shr = lshr i32 %x, 16
  %swaphalf = or i32 %shl, %shr
  %t = shl i32 %swaphalf, 8
  %tand = and i32 %t, 4278255360
  %b = lshr i32 %swaphalf, 8
  %band = and i32 %b, 16711935
  %bswap = or i32 %tand, %band
  ret i32 %bswap
}
=>
define i32 @bswap32_shl_first(i32 %x) {
%0:
  %bswap = bswap i32 %x
  ret i32 %bswap
}
Transformation seems to be correct!


----------------------------------------
define i32 @bswap32_shl_first_extra_use(i32 %x) {
%0:
  %shl = shl i32 %x, 16
  %shr = lshr i32 %x, 16
  %swaphalf = or i32 %shl, %shr
  %t = shl i32 %swaphalf, 8
  %tand = and i32 %t, 4278255360
  %b = lshr i32 %swaphalf, 8
  %band = and i32 %b, 16711935
  %bswap = or i32 %tand, %band
  call void @extra_use(i32 %t)
  ret i32 %bswap
}
=>
define i32 @bswap32_shl_first_extra_use(i32 %x) {
%0:
  %swaphalf = fshl i32 %x, i32 %x, i32 16
  %t = shl i32 %swaphalf, 8
  %bswap = bswap i32 %x
  call void @extra_use(i32 %t)
  ret i32 %bswap
}
Transformation doesn't verify!
ERROR: Timeout


----------------------------------------
define i16 @test8(i16 %a) {
%0:
  %conv = zext i16 %a to i32
  %shr = lshr i16 %a, 8
  %shl = shl i32 %conv, 8
  %conv1 = zext i16 %shr to i32
  %or = or i32 %conv1, %shl
  %conv2 = trunc i32 %or to i16
  ret i16 %conv2
}
=>
define i16 @test8(i16 %a) {
%0:
  %or = bswap i16 %a
  ret i16 %or
}
Transformation seems to be correct!


----------------------------------------
define i16 @test9(i16 %a) {
%0:
  %conv = zext i16 %a to i32
  %shr = lshr i32 %conv, 8
  %shl = shl i32 %conv, 8
  %or = or i32 %shr, %shl
  %conv2 = trunc i32 %or to i16
  ret i16 %conv2
}
=>
define i16 @test9(i16 %a) {
%0:
  %or = bswap i16 %a
  ret i16 %or
}
Transformation seems to be correct!


----------------------------------------
define i16 @test10(i32 %a) {
%0:
  %shr1 = lshr i32 %a, 8
  %and1 = and i32 %shr1, 255
  %and2 = shl i32 %a, 8
  %shl1 = and i32 %and2, 65280
  %or = or i32 %and1, %shl1
  %conv = trunc i32 %or to i16
  ret i16 %conv
}
=>
define i16 @test10(i32 %a) {
%0:
  %trunc = trunc i32 %a to i16
  %rev = bswap i16 %trunc
  ret i16 %rev
}
Transformation seems to be correct!


----------------------------------------
define <2 x i16> @test10_vector(<2 x i32> %a) {
%0:
  %shr1 = lshr <2 x i32> %a, { 8, 8 }
  %and1 = and <2 x i32> %shr1, { 255, 255 }
  %and2 = shl <2 x i32> %a, { 8, 8 }
  %shl1 = and <2 x i32> %and2, { 65280, 65280 }
  %or = or <2 x i32> %and1, %shl1
  %conv = trunc <2 x i32> %or to <2 x i16>
  ret <2 x i16> %conv
}
=>
define <2 x i16> @test10_vector(<2 x i32> %a) {
%0:
  %trunc = trunc <2 x i32> %a to <2 x i16>
  %rev = bswap <2 x i16> %trunc
  ret <2 x i16> %rev
}
Transformation doesn't verify!
ERROR: Timeout


----------------------------------------
define i64 @PR39793_bswap_u64_as_u32(i64 %0) {
%1:
  %2 = lshr i64 %0, 24
  %3 = and i64 %2, 255
  %4 = lshr i64 %0, 8
  %5 = and i64 %4, 65280
  %6 = or i64 %3, %5
  %7 = shl i64 %0, 8
  %8 = and i64 %7, 16711680
  %9 = or i64 %6, %8
  %10 = shl i64 %0, 24
  %11 = and i64 %10, 4278190080
  %12 = or i64 %9, %11
  ret i64 %12
}
=>
define i64 @PR39793_bswap_u64_as_u32(i64 %0) {
%1:
  %trunc = trunc i64 %0 to i32
  %rev = bswap i32 %trunc
  %2 = zext i32 %rev to i64
  ret i64 %2
}
Transformation seems to be correct!


----------------------------------------
define i16 @PR39793_bswap_u64_as_u32_trunc(i64 %0) {
%1:
  %2 = lshr i64 %0, 24
  %3 = and i64 %2, 255
  %4 = lshr i64 %0, 8
  %5 = and i64 %4, 65280
  %6 = or i64 %3, %5
  %7 = shl i64 %0, 8
  %8 = and i64 %7, 16711680
  %9 = or i64 %6, %8
  %10 = shl i64 %0, 24
  %11 = and i64 %10, 4278190080
  %12 = or i64 %9, %11
  %13 = trunc i64 %12 to i16
  ret i16 %13
}
=>
define i16 @PR39793_bswap_u64_as_u32_trunc(i64 %0) {
%1:
  %trunc = trunc i64 %0 to i32
  %rev = bswap i32 %trunc
  %2 = trunc i32 %rev to i16
  ret i16 %2
}
Transformation seems to be correct!


----------------------------------------
define i64 @PR39793_bswap_u64_as_u16(i64 %0) {
%1:
  %2 = lshr i64 %0, 8
  %3 = and i64 %2, 255
  %4 = shl i64 %0, 8
  %5 = and i64 %4, 65280
  %6 = or i64 %3, %5
  ret i64 %6
}
=>
define i64 @PR39793_bswap_u64_as_u16(i64 %0) {
%1:
  %trunc = trunc i64 %0 to i16
  %rev = bswap i16 %trunc
  %2 = zext i16 %rev to i64
  ret i64 %2
}
Transformation seems to be correct!


----------------------------------------
define <2 x i64> @PR39793_bswap_u64_as_u16_vector(<2 x i64> %0) {
%1:
  %2 = lshr <2 x i64> %0, { 8, 8 }
  %3 = and <2 x i64> %2, { 255, 255 }
  %4 = shl <2 x i64> %0, { 8, 8 }
  %5 = and <2 x i64> %4, { 65280, 65280 }
  %6 = or <2 x i64> %3, %5
  ret <2 x i64> %6
}
=>
define <2 x i64> @PR39793_bswap_u64_as_u16_vector(<2 x i64> %0) {
%1:
  %trunc = trunc <2 x i64> %0 to <2 x i16>
  %rev = bswap <2 x i16> %trunc
  %2 = zext <2 x i16> %rev to <2 x i64>
  ret <2 x i64> %2
}
Transformation doesn't verify!
ERROR: Timeout


----------------------------------------
define i8 @PR39793_bswap_u64_as_u16_trunc(i64 %0) {
%1:
  %2 = lshr i64 %0, 8
  %3 = and i64 %2, 255
  %4 = shl i64 %0, 8
  %5 = and i64 %4, 65280
  %6 = or i64 %3, %5
  %7 = trunc i64 %6 to i8
  ret i8 %7
}
=>
define i8 @PR39793_bswap_u64_as_u16_trunc(i64 %0) {
%1:
  %rev1 = lshr i64 %0, 8
  %2 = trunc i64 %rev1 to i8
  ret i8 %2
}
Transformation seems to be correct!


----------------------------------------
define i50 @PR39793_bswap_u50_as_u16(i50 %0) {
%1:
  %2 = lshr i50 %0, 8
  %3 = and i50 %2, 255
  %4 = shl i50 %0, 8
  %5 = and i50 %4, 65280
  %6 = or i50 %3, %5
  ret i50 %6
}
=>
define i50 @PR39793_bswap_u50_as_u16(i50 %0) {
%1:
  %trunc = trunc i50 %0 to i16
  %rev = bswap i16 %trunc
  %2 = zext i16 %rev to i50
  ret i50 %2
}
Transformation seems to be correct!


----------------------------------------
define i32 @PR39793_bswap_u32_as_u16(i32 %0) {
%1:
  %2 = lshr i32 %0, 8
  %3 = and i32 %2, 255
  %4 = shl i32 %0, 8
  %5 = and i32 %4, 65280
  %6 = or i32 %3, %5
  ret i32 %6
}
=>
define i32 @PR39793_bswap_u32_as_u16(i32 %0) {
%1:
  %trunc = trunc i32 %0 to i16
  %rev = bswap i16 %trunc
  %2 = zext i16 %rev to i32
  ret i32 %2
}
Transformation seems to be correct!


----------------------------------------
define i8 @PR39793_bswap_u32_as_u16_trunc(i32 %0) {
%1:
  %2 = lshr i32 %0, 8
  %3 = and i32 %2, 255
  %4 = shl i32 %0, 8
  %5 = and i32 %4, 65280
  %6 = or i32 %3, %5
  %7 = trunc i32 %6 to i8
  ret i8 %7
}
=>
define i8 @PR39793_bswap_u32_as_u16_trunc(i32 %0) {
%1:
  %rev1 = lshr i32 %0, 8
  %2 = trunc i32 %rev1 to i8
  ret i8 %2
}
Transformation seems to be correct!


----------------------------------------
define i32 @partial_bswap(i32 %x) {
%0:
  %x3 = shl i32 %x, 24
  %a2 = shl i32 %x, 8
  %x2 = and i32 %a2, 16711680
  %x32 = or i32 %x3, %x2
  %t1 = and i32 %x, 4294901760
  %t2 = bswap i32 %t1
  %r = or i32 %x32, %t2
  ret i32 %r
}
=>
define i32 @partial_bswap(i32 %x) {
%0:
  %1 = bswap i32 %x
  ret i32 %1
}
Transformation seems to be correct!


----------------------------------------
define <2 x i32> @partial_bswap_vector(<2 x i32> %x) {
%0:
  %x3 = shl <2 x i32> %x, { 24, 24 }
  %a2 = shl <2 x i32> %x, { 8, 8 }
  %x2 = and <2 x i32> %a2, { 16711680, 16711680 }
  %x32 = or <2 x i32> %x3, %x2
  %t1 = and <2 x i32> %x, { 4294901760, 4294901760 }
  %t2 = bswap <2 x i32> %t1
  %r = or <2 x i32> %x32, %t2
  ret <2 x i32> %r
}
=>
define <2 x i32> @partial_bswap_vector(<2 x i32> %x) {
%0:
  %1 = bswap <2 x i32> %x
  ret <2 x i32> %1
}
Transformation doesn't verify!
ERROR: Timeout


----------------------------------------
define i16 @partial_bitreverse(i16 %x) {
%0:
  %rev = bitreverse i16 %x
  %lo = and i16 %rev, 255
  %hi = and i16 %rev, 65280
  %revlo = bitreverse i16 %lo
  %revhi = bitreverse i16 %hi
  %newlo = lshr i16 %revlo, 8
  %newhi = shl i16 %revhi, 8
  %or = or i16 %newlo, %newhi
  ret i16 %or
}
=>
define i16 @partial_bitreverse(i16 %x) {
%0:
  %or = bswap i16 %x
  ret i16 %or
}
Transformation seems to be correct!


----------------------------------------
define i64 @bswap_and_mask_0(i64 %0) {
%1:
  %2 = lshr i64 %0, 56
  %3 = shl i64 %0, 56
  %4 = or i64 %2, %3
  ret i64 %4
}
=>
define i64 @bswap_and_mask_0(i64 %0) {
%1:
  %2 = and i64 %0, -72057594037927681
  %3 = bswap i64 %2
  ret i64 %3
}
Transformation seems to be correct!


----------------------------------------
define i64 @bswap_and_mask_1(i64 %0) {
%1:
  %2 = lshr i64 %0, 56
  %3 = lshr i64 %0, 40
  %4 = and i64 %3, 65280
  %5 = or i64 %4, %2
  ret i64 %5
}
=>
define i64 @bswap_and_mask_1(i64 %0) {
%1:
  %2 = lshr i64 %0, 56
  %3 = lshr i64 %0, 40
  %4 = and i64 %3, 65280
  %5 = or i64 %4, %2
  ret i64 %5
}
Transformation seems to be correct! (syntactically equal)


----------------------------------------
define i64 @bswap_and_mask_2(i64 %0) {
%1:
  %2 = lshr i64 %0, 56
  %3 = shl i64 %0, 56
  %4 = or i64 %2, %3
  %5 = shl i64 %0, 40
  %6 = and i64 %5, 71776119061217280
  %7 = or i64 %4, %6
  ret i64 %7
}
=>
define i64 @bswap_and_mask_2(i64 %0) {
%1:
  %2 = and i64 %0, -72057594037862401
  %3 = bswap i64 %2
  ret i64 %3
}
Transformation seems to be correct!


----------------------------------------
define i64 @bswap_trunc(i64 %x01234567) {
%0:
  %x7zzzzzzz = shl i64 %x01234567, 56
  %xz0123456 = lshr i64 %x01234567, 8
  %xzzzzz012 = lshr i64 %x01234567, 40
  %x3456 = trunc i64 %xz0123456 to i32
  %xz012 = trunc i64 %xzzzzz012 to i32
  %x6543 = bswap i32 %x3456
  %x210z = bswap i32 %xz012
  %xz210 = lshr i32 %x210z, 8
  %xzzzz6543 = zext i32 %x6543 to i64
  %xzzzzz210 = zext i32 %xz210 to i64
  %xz6543zzz = shl i64 %xzzzz6543, 24
  %xz6543210 = or i64 %xzzzzz210, %xz6543zzz
  %x76543210 = or i64 %xz6543210, %x7zzzzzzz
  ret i64 %x76543210
}
=>
define i64 @bswap_trunc(i64 %x01234567) {
%0:
  %x76543210 = bswap i64 %x01234567
  ret i64 %x76543210
}
Transformation seems to be correct!


----------------------------------------
define i32 @shuf_4bytes(<4 x i8> %x) {
%0:
  %bswap = shufflevector <4 x i8> %x, <4 x i8> undef, 3, 2, 1, 0
  %cast = bitcast <4 x i8> %bswap to i32
  ret i32 %cast
}
=>
define i32 @shuf_4bytes(<4 x i8> %x) {
%0:
  %1 = bitcast <4 x i8> %x to i32
  %cast = bswap i32 %1
  ret i32 %cast
}
Transformation seems to be correct!


----------------------------------------
define i32 @shuf_load_4bytes(ptr %p) {
%0:
  %x = load <4 x i8>, ptr %p, align 4
  %bswap = shufflevector <4 x i8> %x, <4 x i8> undef, 3, 2, 4294967295, 0
  %cast = bitcast <4 x i8> %bswap to i32
  ret i32 %cast
}
=>
define i32 @shuf_load_4bytes(ptr %p) {
%0:
  %1 = bitcast ptr %p to ptr
  %x1 = load i32, ptr %1, align 4
  %cast = bswap i32 %x1
  ret i32 %cast
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source

Example:
ptr %p = pointer(non-local, block_id=1, offset=0)

Source:
<4 x i8> %x = < #x00 (0), poison, #x00 (0), #x00 (0) >
<4 x i8> %bswap = < #x00 (0), #x00 (0), any, #x00 (0) >
i32 %cast = #x00000000 (0)	[based on undef value]

SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 >	size: 0	align: 4	alloc type: 0
Block 1 >	size: 8	align: 4	alloc type: 0

Target:
ptr %1 = pointer(non-local, block_id=1, offset=0)
i32 %x1 = poison
i32 %cast = poison
Source value: #x00000000 (0)
Target value: poison


------------------- SMT STATS -------------------
Num queries: 186
Num invalid: 0
Num skips:   0
Num trivial: 137 (42.4%)
Num timeout: 12 (6.5%)
Num errors:  0 (0.0%)
Num SAT:     113 (60.8%)
Num UNSAT:   61 (32.8%)
Alive2: Transform doesn't verify; aborting!

stderr:

+ : 'RUN: at line 2'
+ /home/nlopes/alive2/build/opt-alive.sh -passes=instcombine -S
+ /home/nlopes/llvm/build/bin/FileCheck /home/nlopes/llvm/llvm/test/Transforms/InstCombine/bswap.ll

FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/nlopes/llvm/build/bin/FileCheck /home/nlopes/llvm/llvm/test/Transforms/InstCombine/bswap.ll

 

<-- Back