"%1 = OpVariable %2 Input",
1, "foo"}}), );
+INSTANTIATE_TEST_CASE_P(
+ SimpleIntegralConstants, FriendlyNameTest,
+ ::testing::ValuesIn(std::vector<NameIdCase>{
+ {"%1 = OpTypeInt 32 0 %2 = OpConstant %1 0", 2, "uint_0"},
+ {"%1 = OpTypeInt 32 0 %2 = OpConstant %1 1", 2, "uint_1"},
+ {"%1 = OpTypeInt 32 0 %2 = OpConstant %1 2", 2, "uint_2"},
+ {"%1 = OpTypeInt 32 0 %2 = OpConstant %1 9", 2, "uint_9"},
+ {"%1 = OpTypeInt 32 0 %2 = OpConstant %1 42", 2, "uint_42"},
+ {"%1 = OpTypeInt 32 1 %2 = OpConstant %1 0", 2, "int_0"},
+ {"%1 = OpTypeInt 32 1 %2 = OpConstant %1 1", 2, "int_1"},
+ {"%1 = OpTypeInt 32 1 %2 = OpConstant %1 2", 2, "int_2"},
+ {"%1 = OpTypeInt 32 1 %2 = OpConstant %1 9", 2, "int_9"},
+ {"%1 = OpTypeInt 32 1 %2 = OpConstant %1 42", 2, "int_42"},
+ {"%1 = OpTypeInt 32 1 %2 = OpConstant %1 -42", 2, "int_n42"},
+ // Exotic bit widths
+ {"%1 = OpTypeInt 33 0 %2 = OpConstant %1 0", 2, "u33_0"},
+ {"%1 = OpTypeInt 33 1 %2 = OpConstant %1 10", 2, "i33_10"},
+ {"%1 = OpTypeInt 33 1 %2 = OpConstant %1 -19", 2, "i33_n19"},
+ }), );
+
+INSTANTIATE_TEST_CASE_P(
+ SimpleFloatConstants, FriendlyNameTest,
+ ::testing::ValuesIn(std::vector<NameIdCase>{
+ {"%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1.ff4p+16", 2,
+ "half_0x1_ff4p_16"},
+ {"%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.d2cp-10", 2,
+ "half_n0x1_d2cpn10"},
+ // 32-bit floats
+ {"%1 = OpTypeFloat 32\n%2 = OpConstant %1 -3.275", 2, "float_n3_275"},
+ {"%1 = OpTypeFloat 32\n%2 = OpConstant %1 0x1.8p+128", 2,
+ "float_0x1_8p_128"}, // NaN
+ {"%1 = OpTypeFloat 32\n%2 = OpConstant %1 -0x1.0002p+128", 2,
+ "float_n0x1_0002p_128"}, // NaN
+ {"%1 = OpTypeFloat 32\n%2 = OpConstant %1 0x1p+128", 2,
+ "float_0x1p_128"}, // Inf
+ {"%1 = OpTypeFloat 32\n%2 = OpConstant %1 -0x1p+128", 2,
+ "float_n0x1p_128"}, // -Inf
+ // 64-bit floats
+ {"%1 = OpTypeFloat 64\n%2 = OpConstant %1 -3.275", 2, "double_n3_275"},
+ {"%1 = OpTypeFloat 64\n%2 = OpConstant %1 0x1.ffffffffffffap-1023", 2,
+ "double_0x1_ffffffffffffapn1023"}, // small normal
+ {"%1 = OpTypeFloat 64\n%2 = OpConstant %1 -0x1.ffffffffffffap-1023", 2,
+ "double_n0x1_ffffffffffffapn1023"},
+ {"%1 = OpTypeFloat 64\n%2 = OpConstant %1 0x1.8p+1024", 2,
+ "double_0x1_8p_1024"}, // NaN
+ {"%1 = OpTypeFloat 64\n%2 = OpConstant %1 -0x1.0002p+1024", 2,
+ "double_n0x1_0002p_1024"}, // NaN
+ {"%1 = OpTypeFloat 64\n%2 = OpConstant %1 0x1p+1024", 2,
+ "double_0x1p_1024"}, // Inf
+ {"%1 = OpTypeFloat 64\n%2 = OpConstant %1 -0x1p+1024", 2,
+ "double_n0x1p_1024"}, // -Inf
+ }), );
+
} // anonymous namespace
},
// expected
{
- "%59 = OpConstant %int 1",
- "%60 = OpConstant %int 1",
- "%spec_int_one_vec = OpConstantComposite %v2int %59 %60",
- "%62 = OpConstant %int 0",
- "%63 = OpConstant %int 0",
- "%spec_int_zero_vec = OpConstantComposite %v2int %62 %63",
- "%65 = OpConstant %int 0",
- "%66 = OpConstant %int 0",
- "%spec_int_from_null = OpConstantComposite %v2int %65 %66",
+ "%int_1 = OpConstant %int 1",
+ "%int_1_0 = OpConstant %int 1",
+ "%spec_int_one_vec = OpConstantComposite %v2int %int_1 %int_1_0",
+ "%int_0 = OpConstant %int 0",
+ "%int_0_0 = OpConstant %int 0",
+ "%spec_int_zero_vec = OpConstantComposite %v2int %int_0 %int_0_0",
+ "%int_0_1 = OpConstant %int 0",
+ "%int_0_2 = OpConstant %int 0",
+ "%spec_int_from_null = OpConstantComposite %v2int %int_0_1 %int_0_2",
},
},
},
// expected
{
- "%59 = OpConstant %int 1",
- "%60 = OpConstant %int 1",
- "%spec_int_one_vec = OpConstantComposite %v2int %59 %60",
- "%62 = OpConstant %int 0",
- "%63 = OpConstant %int 0",
- "%spec_int_zero_vec = OpConstantComposite %v2int %62 %63",
- "%65 = OpConstant %int 0",
- "%66 = OpConstant %int 0",
- "%spec_int_from_null = OpConstantComposite %v2int %65 %66",
+ "%int_1 = OpConstant %int 1",
+ "%int_1_0 = OpConstant %int 1",
+ "%spec_int_one_vec = OpConstantComposite %v2int %int_1 %int_1_0",
+ "%int_0 = OpConstant %int 0",
+ "%int_0_0 = OpConstant %int 0",
+ "%spec_int_zero_vec = OpConstantComposite %v2int %int_0 %int_0_0",
+ "%int_0_1 = OpConstant %int 0",
+ "%int_0_2 = OpConstant %int 0",
+ "%spec_int_from_null = OpConstantComposite %v2int %int_0_1 %int_0_2",
},
},
},
// expected
{
- "%59 = OpConstant %uint 1",
- "%60 = OpConstant %uint 1",
- "%spec_uint_one_vec = OpConstantComposite %v2uint %59 %60",
- "%62 = OpConstant %uint 0",
- "%63 = OpConstant %uint 0",
- "%spec_uint_zero_vec = OpConstantComposite %v2uint %62 %63",
- "%65 = OpConstant %uint 0",
- "%66 = OpConstant %uint 0",
- "%spec_uint_from_null = OpConstantComposite %v2uint %65 %66",
+ "%uint_1 = OpConstant %uint 1",
+ "%uint_1_0 = OpConstant %uint 1",
+ "%spec_uint_one_vec = OpConstantComposite %v2uint %uint_1 %uint_1_0",
+ "%uint_0 = OpConstant %uint 0",
+ "%uint_0_0 = OpConstant %uint 0",
+ "%spec_uint_zero_vec = OpConstantComposite %v2uint %uint_0 %uint_0_0",
+ "%uint_0_1 = OpConstant %uint 0",
+ "%uint_0_2 = OpConstant %uint 0",
+ "%spec_uint_from_null = OpConstantComposite %v2uint %uint_0_1 %uint_0_2",
},
},
},
// expected
{
- "%59 = OpConstant %uint 1",
- "%60 = OpConstant %uint 1",
- "%spec_uint_one_vec = OpConstantComposite %v2uint %59 %60",
- "%62 = OpConstant %uint 0",
- "%63 = OpConstant %uint 0",
- "%spec_uint_zero_vec = OpConstantComposite %v2uint %62 %63",
- "%65 = OpConstant %uint 0",
- "%66 = OpConstant %uint 0",
- "%spec_uint_from_null = OpConstantComposite %v2uint %65 %66",
+ "%uint_1 = OpConstant %uint 1",
+ "%uint_1_0 = OpConstant %uint 1",
+ "%spec_uint_one_vec = OpConstantComposite %v2uint %uint_1 %uint_1_0",
+ "%uint_0 = OpConstant %uint 0",
+ "%uint_0_0 = OpConstant %uint 0",
+ "%spec_uint_zero_vec = OpConstantComposite %v2uint %uint_0 %uint_0_0",
+ "%uint_0_1 = OpConstant %uint 0",
+ "%uint_0_2 = OpConstant %uint 0",
+ "%spec_uint_from_null = OpConstantComposite %v2uint %uint_0_1 %uint_0_2",
},
},
// clang-format on
},
// expected
{
- "%59 = OpConstant %int -1",
- "%60 = OpConstant %int -1",
- "%v2int_minus_1 = OpConstantComposite %v2int %59 %60",
- "%62 = OpConstant %int -2",
- "%63 = OpConstant %int -2",
- "%v2int_minus_2 = OpConstantComposite %v2int %62 %63",
- "%65 = OpConstant %int 0",
- "%66 = OpConstant %int 0",
- "%v2int_neg_null = OpConstantComposite %v2int %65 %66",
+ "%int_n1 = OpConstant %int -1",
+ "%int_n1_0 = OpConstant %int -1",
+ "%v2int_minus_1 = OpConstantComposite %v2int %int_n1 %int_n1_0",
+ "%int_n2 = OpConstant %int -2",
+ "%int_n2_0 = OpConstant %int -2",
+ "%v2int_minus_2 = OpConstantComposite %v2int %int_n2 %int_n2_0",
+ "%int_0 = OpConstant %int 0",
+ "%int_0_0 = OpConstant %int 0",
+ "%v2int_neg_null = OpConstantComposite %v2int %int_0 %int_0_0",
},
},
// vector integer (including null vetors) add, sub, div, mul
},
// expected
{
- "%66 = OpConstant %int 5",
- "%67 = OpConstant %int 5",
- "%spec_v2int_iadd = OpConstantComposite %v2int %66 %67",
- "%69 = OpConstant %int -4",
- "%70 = OpConstant %int -4",
- "%spec_v2int_isub = OpConstantComposite %v2int %69 %70",
- "%72 = OpConstant %int -2",
- "%73 = OpConstant %int -2",
- "%spec_v2int_sdiv = OpConstantComposite %v2int %72 %73",
- "%75 = OpConstant %int -6",
- "%76 = OpConstant %int -6",
- "%spec_v2int_imul = OpConstantComposite %v2int %75 %76",
- "%78 = OpConstant %int -6",
- "%79 = OpConstant %int -6",
- "%spec_v2int_iadd_null = OpConstantComposite %v2int %78 %79",
+ "%int_5 = OpConstant %int 5",
+ "%int_5_0 = OpConstant %int 5",
+ "%spec_v2int_iadd = OpConstantComposite %v2int %int_5 %int_5_0",
+ "%int_n4 = OpConstant %int -4",
+ "%int_n4_0 = OpConstant %int -4",
+ "%spec_v2int_isub = OpConstantComposite %v2int %int_n4 %int_n4_0",
+ "%int_n2 = OpConstant %int -2",
+ "%int_n2_0 = OpConstant %int -2",
+ "%spec_v2int_sdiv = OpConstantComposite %v2int %int_n2 %int_n2_0",
+ "%int_n6 = OpConstant %int -6",
+ "%int_n6_0 = OpConstant %int -6",
+ "%spec_v2int_imul = OpConstantComposite %v2int %int_n6 %int_n6_0",
+ "%int_n6_1 = OpConstant %int -6",
+ "%int_n6_2 = OpConstant %int -6",
+ "%spec_v2int_iadd_null = OpConstantComposite %v2int %int_n6_1 %int_n6_2",
- "%81 = OpConstant %uint 5",
- "%82 = OpConstant %uint 5",
- "%spec_v2uint_iadd = OpConstantComposite %v2uint %81 %82",
- "%84 = OpConstant %uint 4294967292",
- "%85 = OpConstant %uint 4294967292",
- "%spec_v2uint_isub = OpConstantComposite %v2uint %84 %85",
- "%87 = OpConstant %uint 1431655764",
- "%88 = OpConstant %uint 1431655764",
- "%spec_v2uint_udiv = OpConstantComposite %v2uint %87 %88",
- "%90 = OpConstant %uint 2863311528",
- "%91 = OpConstant %uint 2863311528",
- "%spec_v2uint_imul = OpConstantComposite %v2uint %90 %91",
- "%93 = OpConstant %uint 2863311528",
- "%94 = OpConstant %uint 2863311528",
- "%spec_v2uint_isub_null = OpConstantComposite %v2uint %93 %94",
+ "%uint_5 = OpConstant %uint 5",
+ "%uint_5_0 = OpConstant %uint 5",
+ "%spec_v2uint_iadd = OpConstantComposite %v2uint %uint_5 %uint_5_0",
+ "%uint_4294967292 = OpConstant %uint 4294967292",
+ "%uint_4294967292_0 = OpConstant %uint 4294967292",
+ "%spec_v2uint_isub = OpConstantComposite %v2uint %uint_4294967292 %uint_4294967292_0",
+ "%uint_1431655764 = OpConstant %uint 1431655764",
+ "%uint_1431655764_0 = OpConstant %uint 1431655764",
+ "%spec_v2uint_udiv = OpConstantComposite %v2uint %uint_1431655764 %uint_1431655764_0",
+ "%uint_2863311528 = OpConstant %uint 2863311528",
+ "%uint_2863311528_0 = OpConstant %uint 2863311528",
+ "%spec_v2uint_imul = OpConstantComposite %v2uint %uint_2863311528 %uint_2863311528_0",
+ "%uint_2863311528_1 = OpConstant %uint 2863311528",
+ "%uint_2863311528_2 = OpConstant %uint 2863311528",
+ "%spec_v2uint_isub_null = OpConstantComposite %v2uint %uint_2863311528_1 %uint_2863311528_2",
},
},
// vector integer rem, mod
"%v2int_minus_3 = OpConstantComposite %v2int %int_minus_3 %int_minus_3",
// srem
- "%73 = OpConstant %int 1",
- "%74 = OpConstant %int 1",
- "%7_srem_3 = OpConstantComposite %v2int %73 %74",
- "%76 = OpConstant %int -1",
- "%77 = OpConstant %int -1",
- "%minus_7_srem_3 = OpConstantComposite %v2int %76 %77",
- "%79 = OpConstant %int 1",
- "%80 = OpConstant %int 1",
- "%7_srem_minus_3 = OpConstantComposite %v2int %79 %80",
- "%82 = OpConstant %int -1",
- "%83 = OpConstant %int -1",
- "%minus_7_srem_minus_3 = OpConstantComposite %v2int %82 %83",
+ "%int_1 = OpConstant %int 1",
+ "%int_1_0 = OpConstant %int 1",
+ "%7_srem_3 = OpConstantComposite %v2int %int_1 %int_1_0",
+ "%int_n1 = OpConstant %int -1",
+ "%int_n1_0 = OpConstant %int -1",
+ "%minus_7_srem_3 = OpConstantComposite %v2int %int_n1 %int_n1_0",
+ "%int_1_1 = OpConstant %int 1",
+ "%int_1_2 = OpConstant %int 1",
+ "%7_srem_minus_3 = OpConstantComposite %v2int %int_1_1 %int_1_2",
+ "%int_n1_1 = OpConstant %int -1",
+ "%int_n1_2 = OpConstant %int -1",
+ "%minus_7_srem_minus_3 = OpConstantComposite %v2int %int_n1_1 %int_n1_2",
// smod
- "%85 = OpConstant %int 1",
- "%86 = OpConstant %int 1",
- "%7_smod_3 = OpConstantComposite %v2int %85 %86",
- "%88 = OpConstant %int 2",
- "%89 = OpConstant %int 2",
- "%minus_7_smod_3 = OpConstantComposite %v2int %88 %89",
- "%91 = OpConstant %int -2",
- "%92 = OpConstant %int -2",
- "%7_smod_minus_3 = OpConstantComposite %v2int %91 %92",
- "%94 = OpConstant %int -1",
- "%95 = OpConstant %int -1",
- "%minus_7_smod_minus_3 = OpConstantComposite %v2int %94 %95",
+ "%int_1_3 = OpConstant %int 1",
+ "%int_1_4 = OpConstant %int 1",
+ "%7_smod_3 = OpConstantComposite %v2int %int_1_3 %int_1_4",
+ "%int_2 = OpConstant %int 2",
+ "%int_2_0 = OpConstant %int 2",
+ "%minus_7_smod_3 = OpConstantComposite %v2int %int_2 %int_2_0",
+ "%int_n2 = OpConstant %int -2",
+ "%int_n2_0 = OpConstant %int -2",
+ "%7_smod_minus_3 = OpConstantComposite %v2int %int_n2 %int_n2_0",
+ "%int_n1_3 = OpConstant %int -1",
+ "%int_n1_4 = OpConstant %int -1",
+ "%minus_7_smod_minus_3 = OpConstantComposite %v2int %int_n1_3 %int_n1_4",
// umod
- "%97 = OpConstant %uint 1",
- "%98 = OpConstant %uint 1",
- "%7_umod_3 = OpConstantComposite %v2uint %97 %98",
+ "%uint_1 = OpConstant %uint 1",
+ "%uint_1_0 = OpConstant %uint 1",
+ "%7_umod_3 = OpConstantComposite %v2uint %uint_1 %uint_1_0",
},
},
// vector integer bitwise, shift
},
// expected
{
- "%64 = OpConstant %int 2",
- "%65 = OpConstant %int 2",
- "%xor_1_3 = OpConstantComposite %v2int %64 %65",
- "%67 = OpConstant %int 0",
- "%68 = OpConstant %int 0",
- "%and_1_2 = OpConstantComposite %v2int %67 %68",
- "%70 = OpConstant %int 3",
- "%71 = OpConstant %int 3",
- "%or_1_2 = OpConstantComposite %v2int %70 %71",
+ "%int_2 = OpConstant %int 2",
+ "%int_2_0 = OpConstant %int 2",
+ "%xor_1_3 = OpConstantComposite %v2int %int_2 %int_2_0",
+ "%int_0 = OpConstant %int 0",
+ "%int_0_0 = OpConstant %int 0",
+ "%and_1_2 = OpConstantComposite %v2int %int_0 %int_0_0",
+ "%int_3 = OpConstant %int 3",
+ "%int_3_0 = OpConstant %int 3",
+ "%or_1_2 = OpConstantComposite %v2int %int_3 %int_3_0",
"%unsigned_31 = OpConstant %uint 31",
"%v2unsigned_31 = OpConstantComposite %v2uint %unsigned_31 %unsigned_31",
- "%73 = OpConstant %uint 2147483648",
- "%74 = OpConstant %uint 2147483648",
- "%unsigned_left_shift_max = OpConstantComposite %v2uint %73 %74",
- "%76 = OpConstant %uint 1",
- "%77 = OpConstant %uint 1",
- "%unsigned_right_shift_logical = OpConstantComposite %v2uint %76 %77",
- "%79 = OpConstant %int -1",
- "%80 = OpConstant %int -1",
- "%signed_right_shift_arithmetic = OpConstantComposite %v2int %79 %80",
+ "%uint_2147483648 = OpConstant %uint 2147483648",
+ "%uint_2147483648_0 = OpConstant %uint 2147483648",
+ "%unsigned_left_shift_max = OpConstantComposite %v2uint %uint_2147483648 %uint_2147483648_0",
+ "%uint_1 = OpConstant %uint 1",
+ "%uint_1_0 = OpConstant %uint 1",
+ "%unsigned_right_shift_logical = OpConstantComposite %v2uint %uint_1 %uint_1_0",
+ "%int_n1 = OpConstant %int -1",
+ "%int_n1_0 = OpConstant %int -1",
+ "%signed_right_shift_arithmetic = OpConstantComposite %v2int %int_n1 %int_n1_0",
},
},
// Skip folding if any vector operands or components of the operands
"%spec_int_19 = OpConstant %int -1",
"%spec_int_20 = OpConstant %int 101",
"%used_vec_a = OpConstantComposite %v2int %spec_int_18 %spec_int_19",
- "%104 = OpConstant %int 10201",
- "%105 = OpConstant %int 1",
- "%used_vec_b = OpConstantComposite %v2int %104 %105",
+ "%int_10201 = OpConstant %int 10201",
+ "%int_1 = OpConstant %int 1",
+ "%used_vec_b = OpConstantComposite %v2int %int_10201 %int_1",
"%spec_int_21 = OpConstant %int 10201",
"%array = OpConstantComposite %type_arr_int_4 %spec_int_20 %spec_int_20 %spec_int_21 %spec_int_21",
"%spec_int_22 = OpSpecConstant %int 123",