-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ir: add syntactic support for scalable vectors
As a first step towards verifying programs with scalable vectors, add syntactic support with vscale implicitly assumed to be 1. This assumption should be conservatively correct for the purposes of verification.
- Loading branch information
Showing
7 changed files
with
85 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
define i32 @src(i32 %a) { | ||
%poison = add nsw i32 2147483647, 100 | ||
%v = insertelement <vscale x 2 x i32> undef, i32 %a, i32 0 | ||
%v2 = insertelement <vscale x 2 x i32> %v, i32 %poison, i32 1 | ||
%w = extractelement <vscale x 2 x i32> %v2, i32 0 | ||
ret i32 %w | ||
} | ||
|
||
define i32 @tgt(i32 %a) { | ||
%poison = add nsw i32 2147483647, 100 | ||
ret i32 %poison | ||
} | ||
|
||
; ERROR: Target is more poisonous than source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
define <vscale x 2 x i8> @src(<vscale x 2 x i8> %x) { | ||
%rem.i = srem <vscale x 2 x i8> %x, splat(i8 2) | ||
%cmp.i = icmp slt <vscale x 2 x i8> %rem.i, zeroinitializer | ||
%add.i = select <vscale x 2 x i1> %cmp.i, <vscale x 2 x i8> splat(i8 2), <vscale x 2 x i8> zeroinitializer | ||
ret <vscale x 2 x i8> %add.i | ||
} | ||
|
||
define <vscale x 2 x i8> @tgt(<vscale x 2 x i8> %x) { | ||
%rem.i = srem <vscale x 2 x i8> %x, splat(i8 2) | ||
%tmp1 = and <vscale x 2 x i8> %rem.i, splat(i8 2) | ||
ret <vscale x 2 x i8> %tmp1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
define <vscale x 2 x ptr> @src() { | ||
%a = getelementptr i8, ptr undef, <vscale x 2 x i64> zeroinitializer | ||
ret <vscale x 2 x ptr> %a | ||
} | ||
|
||
define <2 x ptr> @tgt() { | ||
ret <2 x ptr> undef | ||
} | ||
|
||
; CHECK: ERROR: program doesn't type check! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
define <vscale x 2 x ptr> @src() { | ||
%a = getelementptr i8, ptr undef, <vscale x 2 x i64> zeroinitializer | ||
ret <vscale x 2 x ptr> %a | ||
} | ||
|
||
define <vscale x 2 x ptr> @tgt() { | ||
ret <vscale x 2 x ptr> undef | ||
} |