-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DAPHNE-#772] Fix Constant folding crashes for values of different types
- add type promotion to the smaller bit width type - added testcases for binary op of different types Closes #813
- Loading branch information
1 parent
5337d14
commit 1e7e3bc
Showing
4 changed files
with
129 additions
and
41 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
16 changes: 16 additions & 0 deletions
16
test/api/cli/operations/binary_op_casts_constant_folding.daphne
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,16 @@ | ||
print(1 + as.si8(1)); | ||
print(2 + as.si32(1)); | ||
print(3 + as.si64(1)); | ||
print(4 + as.ui8(1)); | ||
print(5 + as.ui32(1)); | ||
print(6 + as.ui64(1)); | ||
|
||
print(10.0 + as.f32(1)); | ||
print(11.0 + as.f64(1)); | ||
|
||
print(as.si32(7) + as.si8(1)); | ||
print(as.si64(8) + as.si32(1)); | ||
print(as.si8(9) + as.si64(1)); | ||
|
||
print(as.f64(12.0) + as.f32(1)); | ||
print(as.f32(13.0) + as.f64(1)); |
34 changes: 34 additions & 0 deletions
34
test/api/cli/operations/binary_op_casts_constant_folding.txt
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,34 @@ | ||
IR after parsing and some simplifications: | ||
module { | ||
func.func @main() { | ||
%0 = "daphne.constant"() {value = 1.400000e+01 : f64} : () -> f64 | ||
%1 = "daphne.constant"() {value = 1.300000e+01 : f64} : () -> f64 | ||
%2 = "daphne.constant"() {value = 1.200000e+01 : f64} : () -> f64 | ||
%3 = "daphne.constant"() {value = 10 : si64} : () -> si64 | ||
%4 = "daphne.constant"() {value = 9 : si64} : () -> si64 | ||
%5 = "daphne.constant"() {value = 8 : si32} : () -> si32 | ||
%6 = "daphne.constant"() {value = 1.100000e+01 : f64} : () -> f64 | ||
%7 = "daphne.constant"() {value = 7 : ui64} : () -> ui64 | ||
%8 = "daphne.constant"() {value = 6 : si64} : () -> si64 | ||
%9 = "daphne.constant"() {value = 5 : si64} : () -> si64 | ||
%10 = "daphne.constant"() {value = 4 : si64} : () -> si64 | ||
%11 = "daphne.constant"() {value = 3 : si64} : () -> si64 | ||
%12 = "daphne.constant"() {value = 2 : si64} : () -> si64 | ||
%13 = "daphne.constant"() {value = false} : () -> i1 | ||
%14 = "daphne.constant"() {value = true} : () -> i1 | ||
"daphne.print"(%12, %14, %13) : (si64, i1, i1) -> () | ||
"daphne.print"(%11, %14, %13) : (si64, i1, i1) -> () | ||
"daphne.print"(%10, %14, %13) : (si64, i1, i1) -> () | ||
"daphne.print"(%9, %14, %13) : (si64, i1, i1) -> () | ||
"daphne.print"(%8, %14, %13) : (si64, i1, i1) -> () | ||
"daphne.print"(%7, %14, %13) : (ui64, i1, i1) -> () | ||
"daphne.print"(%6, %14, %13) : (f64, i1, i1) -> () | ||
"daphne.print"(%2, %14, %13) : (f64, i1, i1) -> () | ||
"daphne.print"(%5, %14, %13) : (si32, i1, i1) -> () | ||
"daphne.print"(%4, %14, %13) : (si64, i1, i1) -> () | ||
"daphne.print"(%3, %14, %13) : (si64, i1, i1) -> () | ||
"daphne.print"(%1, %14, %13) : (f64, i1, i1) -> () | ||
"daphne.print"(%0, %14, %13) : (f64, i1, i1) -> () | ||
"daphne.return"() : () -> () | ||
} | ||
} |