diff options
author | Sanjay Patel <spatel@rotateright.com> | 2017-10-13 17:42:12 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2017-10-13 17:42:12 +0000 |
commit | 399fcbea37afc33f9609652e4b085affa9164d83 (patch) | |
tree | ecf13ec0996058f7908ceb7da84929335d84aa47 | |
parent | e29452b4b7a81269cb02bcfc995e7f1fc99b3845 (diff) | |
download | bcm5719-llvm-399fcbea37afc33f9609652e4b085affa9164d83.tar.gz bcm5719-llvm-399fcbea37afc33f9609652e4b085affa9164d83.zip |
[InstCombine] add tests for add (zext (add nuw X, C2)), C --> zext (add nuw X, C2 + C); NFC
llvm-svn: 315717
-rw-r--r-- | llvm/test/Transforms/InstCombine/add.ll | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/add.ll b/llvm/test/Transforms/InstCombine/add.ll index 7502152f675..728262a208a 100644 --- a/llvm/test/Transforms/InstCombine/add.ll +++ b/llvm/test/Transforms/InstCombine/add.ll @@ -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 |