diff options
author | Sanjay Patel <spatel@rotateright.com> | 2017-07-02 16:05:11 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2017-07-02 16:05:11 +0000 |
commit | b51e072d358b8936034e22327cdf20105f7a4654 (patch) | |
tree | ed2c98c5760714e5036e6c488600e9d14d01ccc4 /llvm/test | |
parent | 7d263c1a2782ade7e2465e4dbb988f0a864827cb (diff) | |
download | bcm5719-llvm-b51e072d358b8936034e22327cdf20105f7a4654.tar.gz bcm5719-llvm-b51e072d358b8936034e22327cdf20105f7a4654.zip |
[InstCombine] fix crash when folding cmp+bswap vector
We assumed the constant was a scalar when creating the replacement operand.
Also, improve tests for this fold and move the tests for this fold to their own file.
I'll move the related and missing tests to this file as a follow-up.
llvm-svn: 306985
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/Transforms/InstCombine/bswap-fold.ll | 30 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/cmp-intrinsic.ll | 36 |
2 files changed, 36 insertions, 30 deletions
diff --git a/llvm/test/Transforms/InstCombine/bswap-fold.ll b/llvm/test/Transforms/InstCombine/bswap-fold.ll index 91678a91962..1e80c9be66f 100644 --- a/llvm/test/Transforms/InstCombine/bswap-fold.ll +++ b/llvm/test/Transforms/InstCombine/bswap-fold.ll @@ -1,35 +1,5 @@ ; RUN: opt < %s -instcombine -S | FileCheck %s -define i1 @test1(i16 %t) { -; CHECK-LABEL: @test1( -; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i16 %t, 256 -; CHECK-NEXT: ret i1 [[TMP2]] -; - %tmp1 = call i16 @llvm.bswap.i16( i16 %t ) - %tmp2 = icmp eq i16 %tmp1, 1 - ret i1 %tmp2 -} - -define i1 @test2(i32 %tmp) { -; CHECK-LABEL: @test2( -; CHECK-NEXT: [[TMP_UPGRD_1:%.*]] = icmp eq i32 %tmp, 16777216 -; CHECK-NEXT: ret i1 [[TMP_UPGRD_1]] -; - %tmp34 = tail call i32 @llvm.bswap.i32( i32 %tmp ) - %tmp.upgrd.1 = icmp eq i32 %tmp34, 1 - ret i1 %tmp.upgrd.1 -} - -define i1 @test3(i64 %tmp) { -; CHECK-LABEL: @test3( -; CHECK-NEXT: [[TMP_UPGRD_2:%.*]] = icmp eq i64 %tmp, 72057594037927936 -; CHECK-NEXT: ret i1 [[TMP_UPGRD_2]] -; - %tmp34 = tail call i64 @llvm.bswap.i64( i64 %tmp ) - %tmp.upgrd.2 = icmp eq i64 %tmp34, 1 - ret i1 %tmp.upgrd.2 -} - ; rdar://5992453 ; A & 255 define i32 @test4(i32 %a) nounwind { diff --git a/llvm/test/Transforms/InstCombine/cmp-intrinsic.ll b/llvm/test/Transforms/InstCombine/cmp-intrinsic.ll new file mode 100644 index 00000000000..723a97f6ea1 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/cmp-intrinsic.ll @@ -0,0 +1,36 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s + +declare i16 @llvm.bswap.i16(i16) +declare i32 @llvm.bswap.i32(i32) +declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>) + +define i1 @bswap_eq_i16(i16 %x) { +; CHECK-LABEL: @bswap_eq_i16( +; CHECK-NEXT: [[CMP:%.*]] = icmp eq i16 %x, 256 +; CHECK-NEXT: ret i1 [[CMP]] +; + %bs = call i16 @llvm.bswap.i16(i16 %x) + %cmp = icmp eq i16 %bs, 1 + ret i1 %cmp +} + +define i1 @bswap_ne_i32(i32 %x) { +; CHECK-LABEL: @bswap_ne_i32( +; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 %x, 33554432 +; CHECK-NEXT: ret i1 [[CMP]] +; + %bs = tail call i32 @llvm.bswap.i32(i32 %x) + %cmp = icmp ne i32 %bs, 2 + ret i1 %cmp +} + +define <2 x i1> @bswap_eq_v2i64(<2 x i64> %x) { +; CHECK-LABEL: @bswap_eq_v2i64( +; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i64> %x, <i64 216172782113783808, i64 216172782113783808> +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %bs = tail call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %x) + %cmp = icmp eq <2 x i64> %bs, <i64 3, i64 3> + ret <2 x i1> %cmp +} + |