-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2301 from Smit-create/flip_sign
PASS: Update FlipSign pass to use Intrinsic Function
- Loading branch information
Showing
6 changed files
with
130 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from lpython import f32, i32 | ||
|
||
def flip_sign_check(): | ||
x: f32 | ||
eps: f32 = f32(1e-5) | ||
|
||
number: i32 = 123 | ||
x = f32(5.5) | ||
|
||
if (number%2 == 1): | ||
x = -x | ||
|
||
assert abs(x - f32(-5.5)) < eps | ||
|
||
number = 124 | ||
x = f32(5.5) | ||
|
||
if (number%2 == 1): | ||
x = -x | ||
|
||
assert abs(x - f32(5.5)) < eps | ||
|
||
flip_sign_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
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