[llvm] r315717 - [InstCombine] add tests for add (zext (add nuw X, C2)), C --> zext (add nuw X, C2 + C); NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 13 10:42:12 PDT 2017


Author: spatel
Date: Fri Oct 13 10:42:12 2017
New Revision: 315717

URL: http://llvm.org/viewvc/llvm-project?rev=315717&view=rev
Log:
[InstCombine] add tests for add (zext (add nuw X, C2)), C --> zext (add nuw X, C2 + C); NFC

Modified:
    llvm/trunk/test/Transforms/InstCombine/add.ll

Modified: llvm/trunk/test/Transforms/InstCombine/add.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/add.ll?rev=315717&r1=315716&r2=315717&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/add.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/add.ll Fri Oct 13 10:42:12 2017
@@ -601,6 +601,8 @@ define i1 @test40(i32 %a, i32 %b) {
   ret i1 %cmp
 }
 
+; (add (zext (add nuw X, C2)), C) --> (zext (add nuw X, C2 + C))
+
 define i64 @test41(i32 %a) {
 ; CHECK-LABEL: @test41(
 ; CHECK-NEXT:    [[ADD:%.*]] = add nuw i32 %a, 15
@@ -613,6 +615,36 @@ define i64 @test41(i32 %a) {
   ret i64 %sub
 }
 
+; (add (zext (add nuw X, C2)), C) --> (zext (add nuw X, C2 + C))
+
+define <2 x i64> @test41vec(<2 x i32> %a) {
+; CHECK-LABEL: @test41vec(
+; CHECK-NEXT:    [[TMP1:%.*]] = add nuw <2 x i32> %a, <i32 15, i32 15>
+; CHECK-NEXT:    [[SUB:%.*]] = zext <2 x i32> [[TMP1]] to <2 x i64>
+; CHECK-NEXT:    ret <2 x i64> [[SUB]]
+;
+  %add = add nuw <2 x i32> %a, <i32 16, i32 16>
+  %zext = zext <2 x i32> %add to <2 x i64>
+  %sub = add <2 x i64> %zext, <i64 -1, i64 -1>
+  ret <2 x i64> %sub
+}
+
+define <2 x i64> @test41vec_and_multiuse(<2 x i32> %a) {
+; CHECK-LABEL: @test41vec_and_multiuse(
+; CHECK-NEXT:    [[ADD:%.*]] = add nuw <2 x i32> %a, <i32 16, i32 16>
+; CHECK-NEXT:    [[ZEXT:%.*]] = zext <2 x i32> [[ADD]] to <2 x i64>
+; CHECK-NEXT:    [[TMP1:%.*]] = add nuw <2 x i32> %a, <i32 15, i32 15>
+; CHECK-NEXT:    [[SUB:%.*]] = zext <2 x i32> [[TMP1]] to <2 x i64>
+; CHECK-NEXT:    [[EXTRAUSE:%.*]] = add nuw nsw <2 x i64> [[ZEXT]], [[SUB]]
+; CHECK-NEXT:    ret <2 x i64> [[EXTRAUSE]]
+;
+  %add = add nuw <2 x i32> %a, <i32 16, i32 16>
+  %zext = zext <2 x i32> %add to <2 x i64>
+  %sub = add <2 x i64> %zext, <i64 -1, i64 -1>
+  %extrause = add <2 x i64> %zext, %sub
+  ret <2 x i64> %extrause
+}
+
 define i32 @test42(i1 %C) {
 ; CHECK-LABEL: @test42(
 ; CHECK-NEXT:    [[V:%.*]] = select i1 [[C:%.*]], i32 1123, i32 133




More information about the llvm-commits mailing list