[flang-commits] [flang] 2ab0aea - [flang][NFC] Test folding F08 mask intrinsics
Tarun Prabhu via flang-commits
flang-commits at lists.llvm.org
Thu Jul 21 22:32:55 PDT 2022
Author: Tarun Prabhu
Date: 2022-07-21T23:30:38-06:00
New Revision: 2ab0aeaae2e8f870b9d5b5556e1328d50318eb8f
URL: https://github.com/llvm/llvm-project/commit/2ab0aeaae2e8f870b9d5b5556e1328d50318eb8f
DIFF: https://github.com/llvm/llvm-project/commit/2ab0aeaae2e8f870b9d5b5556e1328d50318eb8f.diff
LOG: [flang][NFC] Test folding F08 mask intrinsics
Test compile-time folding of F08 maskl and maskr intrinsics.
Differential Revision: https://reviews.llvm.org/D129663
Added:
flang/test/Evaluate/fold-mask.f90
Modified:
Removed:
################################################################################
diff --git a/flang/test/Evaluate/fold-mask.f90 b/flang/test/Evaluate/fold-mask.f90
new file mode 100644
index 000000000000..741003011cab
--- /dev/null
+++ b/flang/test/Evaluate/fold-mask.f90
@@ -0,0 +1,102 @@
+! RUN: %python %S/test_folding.py %s %flang_fc1
+
+! Test mask intrinsic folding
+
+module maskltest
+ logical, parameter :: test_l0 = maskl(0) .EQ. 0
+ logical, parameter :: test_l1 = maskl(1) .EQ. -2147483648_8
+ logical, parameter :: test_l2 = maskl(2) .EQ. -1073741824
+ logical, parameter :: test_lm = maskl(16) .EQ. -65536
+ logical, parameter :: test_le1 = maskl(31) .EQ. -2
+ logical, parameter :: test_le = maskl(32) .EQ. -1
+ logical, parameter :: test_lo = maskl(33) .EQ. -1
+
+ logical, parameter :: test_l0_1 = maskl(0, 1) .EQ. 0_1
+ logical, parameter :: test_l1_1 = maskl(1, 1) .EQ. -128_2
+ logical, parameter :: test_l2_1 = maskl(2, 1) .EQ. -64_1
+ logical, parameter :: test_lm_1 = maskl(4, 1) .EQ. -16_1
+ logical, parameter :: test_le1_1 = maskl(7, 1) .EQ. -2_1
+ logical, parameter :: test_le_1 = maskl(8, 1) .EQ. -1_1
+ logical, parameter :: test_lo_1 = maskl(9, 1) .EQ. -1_1
+
+ logical, parameter :: test_l0_2 = maskl(0, 2) .EQ. 0_2
+ logical, parameter :: test_l1_2 = maskl(1, 2) .EQ. -32768_4
+ logical, parameter :: test_l2_2 = maskl(2, 2) .EQ. -16384_2
+ logical, parameter :: test_lm_2 = maskl(8, 2) .EQ. -256_2
+ logical, parameter :: test_le1_2 = maskl(15, 2) .EQ. -2_2
+ logical, parameter :: test_le_2 = maskl(16, 2) .EQ. -1_2
+ logical, parameter :: test_lo_2 = maskl(17, 2) .EQ. -1_2
+
+ logical, parameter :: test_l0_4 = maskl(0, 4) .EQ. 0_4
+ logical, parameter :: test_l1_4 = maskl(1, 4) .EQ. -2147483648_8
+ logical, parameter :: test_l2_4 = maskl(2, 4) .EQ. -1073741824_4
+ logical, parameter :: test_lm_4 = maskl(16, 4) .EQ. -65536_4
+ logical, parameter :: test_le1_4 = maskl(31, 4) .EQ. -2_4
+ logical, parameter :: test_le_4 = maskl(32, 4) .EQ. -1_4
+ logical, parameter :: test_lo_4 = maskl(33, 4) .EQ. -1_4
+
+ logical, parameter :: test_l0_8 = maskl(0, 8) .EQ. 0_8
+ logical, parameter :: test_l1_8 = maskl(1, 8) .EQ. -9223372036854775808_16
+ logical, parameter :: test_l2_8 = maskl(2, 8) .EQ. -4611686018427387904_8
+ logical, parameter :: test_lm_8 = maskl(32, 8) .EQ. -4294967296_8
+ logical, parameter :: test_le1_8 = maskl(63, 8) .EQ. -2_8
+ logical, parameter :: test_le_8 = maskl(64, 8) .EQ. -1_8
+ logical, parameter :: test_lo_8 = maskl(65, 8) .EQ. -1_8
+
+ logical, parameter :: test_l0_16 = maskl(0, 16) .EQ. 0_16
+ logical, parameter :: test_l2_16 = maskl(2, 16) .EQ. -85070591730234615865843651857942052864_16
+ logical, parameter :: test_lm_16 = maskl(64, 16) .EQ. -18446744073709551616_16
+ logical, parameter :: test_le1_16 = maskl(127, 16) .EQ. -2_16
+ logical, parameter :: test_le_16 = maskl(128, 16) .EQ. -1_16
+ logical, parameter :: test_lo_16 = maskl(129, 16) .EQ. -1_16
+end module maskltest
+
+module maskrtest
+ logical, parameter :: test_r0 = maskr(0) .EQ. 0
+ logical, parameter :: test_r1 = maskr(1) .EQ. 1
+ logical, parameter :: test_r2 = maskr(2) .EQ. 3
+ logical, parameter :: test_rm = maskr(16) .EQ. 65535
+ logical, parameter :: test_re1 = maskr(31) .EQ. 2147483647
+ logical, parameter :: test_re = maskr(32) .EQ. -1
+ logical, parameter :: test_ro = maskr(33) .EQ. -1
+
+ logical, parameter :: test_r0_1 = maskr(0, 1) .EQ. 0_1
+ logical, parameter :: test_r1_1 = maskr(1, 1) .EQ. 1_1
+ logical, parameter :: test_r2_1 = maskr(2, 1) .EQ. 3_1
+ logical, parameter :: test_rm_1 = maskr(4, 1) .EQ. 15_1
+ logical, parameter :: test_re1_1 = maskr(7, 1) .EQ. 127_1
+ logical, parameter :: test_re_1 = maskr(8, 1) .EQ. -1_1
+ logical, parameter :: test_ro_1 = maskr(9, 1) .EQ. -1_1
+
+ logical, parameter :: test_r0_2 = maskr(0, 2) .EQ. 0_2
+ logical, parameter :: test_r1_2 = maskr(1, 2) .EQ. 1_2
+ logical, parameter :: test_r2_2 = maskr(2, 2) .EQ. 3_2
+ logical, parameter :: test_rm_2 = maskr(8, 2) .EQ. 255_2
+ logical, parameter :: test_re1_2 = maskr(15, 2) .EQ. 32767_2
+ logical, parameter :: test_re_2 = maskr(16, 2) .EQ. -1_2
+ logical, parameter :: test_ro_2 = maskr(17, 2) .EQ. -1_2
+
+ logical, parameter :: test_r0_4 = maskr(0, 4) .EQ. 0_4
+ logical, parameter :: test_r1_4 = maskr(1, 4) .EQ. 1_4
+ logical, parameter :: test_r2_4 = maskr(2, 4) .EQ. 3_4
+ logical, parameter :: test_rm_4 = maskr(16, 4) .EQ. 65535_4
+ logical, parameter :: test_re1_4 = maskr(31, 4) .EQ. 2147483647_4
+ logical, parameter :: test_re_4 = maskr(32, 4) .EQ. -1_4
+ logical, parameter :: test_ro_4 = maskr(33, 4) .EQ. -1_4
+
+ logical, parameter :: test_r0_8 = maskr(0, 8) .EQ. 0_8
+ logical, parameter :: test_r1_8 = maskr(1, 8) .EQ. 1_8
+ logical, parameter :: test_r2_8 = maskr(2, 8) .EQ. 3_8
+ logical, parameter :: test_rm_8 = maskr(32, 8) .EQ. 4294967295_8
+ logical, parameter :: test_re1_8 = maskr(63, 8) .EQ. 9223372036854775807_8
+ logical, parameter :: test_re_8 = maskr(64, 8) .EQ. -1_8
+ logical, parameter :: test_ro_8 = maskr(65, 8) .EQ. -1_8
+
+ logical, parameter :: test_r0_16 = maskr(0, 16) .EQ. 0_16
+ logical, parameter :: test_r1_16 = maskr(1, 16) .EQ. 1_16
+ logical, parameter :: test_r2_16 = maskr(2, 16) .EQ. 3_16
+ logical, parameter :: test_rm_16 = maskr(64, 16) .EQ. 18446744073709551615_16
+ logical, parameter :: test_re1_16 = maskr(127, 16) .EQ. 170141183460469231731687303715884105727_16
+ logical, parameter :: test_re_16 = maskr(128, 16) .EQ. -1_16
+ logical, parameter :: test_ro_16 = maskr(129, 16) .EQ. -1_16
+end module maskrtest
More information about the flang-commits
mailing list