From fb0e1f524b50d34bcb2c8cfc71aed8eaf2055775 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 2 Aug 2017 06:35:15 +0000 Subject: [PATCH] [InstCombine] Add test cases for 'or' and 'xor' to match the vector 'and' of 'sext' of 'cmp' test. When the 'and' test was originally added it was intended to make sure we didn't change it to a sext of and of cmp. But since then the test was changed to expect it to be turned into 'select cmp1, sext cmp2, 0'. Then another optimization was added to turn the select into 'sext (and cmp1, cmp2)' which is exactly the transformation that was being blocked when the test case started. Looks like 'or' gets optimized in a similar way, but not 'xor'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309793 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/vector-casts.ll | 37 +++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/Transforms/InstCombine/vector-casts.ll b/test/Transforms/InstCombine/vector-casts.ll index 2197c250ace..e52e063a405 100644 --- a/test/Transforms/InstCombine/vector-casts.ll +++ b/test/Transforms/InstCombine/vector-casts.ll @@ -75,6 +75,43 @@ define <2 x i64> @test5(<4 x float> %a, <4 x float> %b) { ret <2 x i64> %conv } +define <2 x i64> @test6(<4 x float> %a, <4 x float> %b) { +; CHECK-LABEL: @test6( +; CHECK-NEXT: [[CMP:%.*]] = fcmp ult <4 x float> [[A:%.*]], zeroinitializer +; CHECK-NEXT: [[CMP4:%.*]] = fcmp ult <4 x float> [[B:%.*]], zeroinitializer +; CHECK-NEXT: [[NARROW:%.*]] = or <4 x i1> [[CMP]], [[CMP4]] +; CHECK-NEXT: [[AND:%.*]] = sext <4 x i1> [[NARROW]] to <4 x i32> +; CHECK-NEXT: [[CONV:%.*]] = bitcast <4 x i32> [[AND]] to <2 x i64> +; CHECK-NEXT: ret <2 x i64> [[CONV]] +; + %cmp = fcmp ult <4 x float> %a, zeroinitializer + %sext = sext <4 x i1> %cmp to <4 x i32> + %cmp4 = fcmp ult <4 x float> %b, zeroinitializer + %sext5 = sext <4 x i1> %cmp4 to <4 x i32> + %and = or <4 x i32> %sext, %sext5 + %conv = bitcast <4 x i32> %and to <2 x i64> + ret <2 x i64> %conv +} + +define <2 x i64> @test7(<4 x float> %a, <4 x float> %b) { +; CHECK-LABEL: @test7( +; CHECK-NEXT: [[CMP:%.*]] = fcmp ult <4 x float> [[A:%.*]], zeroinitializer +; CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32> +; CHECK-NEXT: [[CMP4:%.*]] = fcmp ult <4 x float> [[B:%.*]], zeroinitializer +; CHECK-NEXT: [[SEXT5:%.*]] = sext <4 x i1> [[CMP4]] to <4 x i32> +; CHECK-NEXT: [[AND:%.*]] = xor <4 x i32> [[SEXT]], [[SEXT5]] +; CHECK-NEXT: [[CONV:%.*]] = bitcast <4 x i32> [[AND]] to <2 x i64> +; CHECK-NEXT: ret <2 x i64> [[CONV]] +; + %cmp = fcmp ult <4 x float> %a, zeroinitializer + %sext = sext <4 x i1> %cmp to <4 x i32> + %cmp4 = fcmp ult <4 x float> %b, zeroinitializer + %sext5 = sext <4 x i1> %cmp4 to <4 x i32> + %and = xor <4 x i32> %sext, %sext5 + %conv = bitcast <4 x i32> %and to <2 x i64> + ret <2 x i64> %conv +} + define void @convert(<2 x i32>* %dst.addr, <2 x i64> %src) { ; CHECK-LABEL: @convert( ; CHECK-NEXT: [[VAL:%.*]] = trunc <2 x i64> %src to <2 x i32> -- 2.40.0