Skip to content

Instantly share code, notes, and snippets.

@iluuu1994
Created July 11, 2020 15:09
Show Gist options
  • Save iluuu1994/6427acd37750614f6895c42c2338ee24 to your computer and use it in GitHub Desktop.
Save iluuu1994/6427acd37750614f6895c42c2338ee24 to your computer and use it in GitHub Desktop.
Match misoptimization
$_main:
; (lines=72, args=0, vars=1, tmps=19)
; (before optimizer)
; /tmp/php-src/Zend/tests/match/039.phpt:1-62
; return [] RANGE[0..0]
0000 ECHO string("--TEST--
Test match with duplicate conditions
--FILE--
")
0001 ASSIGN CV0($value) int(1)
0002 MATCH CV0($value) 1: 0003, 2: 0005, 3: 0007, 4: 0009, 5: 0011, default: 0015
0003 T3 = QM_ASSIGN int(1)
0004 JMP 0016
0005 T3 = QM_ASSIGN int(2)
0006 JMP 0016
0007 T3 = QM_ASSIGN int(3)
0008 JMP 0016
0009 T3 = QM_ASSIGN int(4)
0010 JMP 0016
0011 T3 = QM_ASSIGN int(5)
0012 JMP 0016
0013 T3 = QM_ASSIGN int(6)
0014 JMP 0016
0015 T3 = MATCH_ERROR CV0($value)
0016 ECHO T3
0017 ECHO string("
")
0018 MATCH CV0($value) 2: 0019, 1: 0019, 3: 0023, 4: 0025, 5: 0027, default: 0029
0019 T6 = QM_ASSIGN string("2, 1")
0020 JMP 0030
0021 T6 = QM_ASSIGN int(1)
0022 JMP 0030
0023 T6 = QM_ASSIGN int(3)
0024 JMP 0030
0025 T6 = QM_ASSIGN int(4)
0026 JMP 0030
0027 T6 = QM_ASSIGN int(5)
0028 JMP 0030
0029 T6 = MATCH_ERROR CV0($value)
0030 ECHO T6
0031 ECHO string("
")
0032 MATCH CV0($value) 1: 0033, 2: 0035, 3: 0037, 4: 0039, 5: 0041, default: 0043
0033 T9 = QM_ASSIGN string("1, 1")
0034 JMP 0044
0035 T9 = QM_ASSIGN string("2, 2")
0036 JMP 0044
0037 T9 = QM_ASSIGN string("3, 3")
0038 JMP 0044
0039 T9 = QM_ASSIGN string("4, 4")
0040 JMP 0044
0041 T9 = QM_ASSIGN string("5, 5")
0042 JMP 0044
0043 T9 = MATCH_ERROR CV0($value)
0044 ECHO T9
0045 ECHO string("
")
0046 MATCH CV0($value) 1: 0047, default: 0051
0047 T12 = QM_ASSIGN int(1)
0048 JMP 0052
0049 T12 = QM_ASSIGN int(2)
0050 JMP 0052
0051 T12 = MATCH_ERROR CV0($value)
0052 ECHO T12
0053 ECHO string("
")
0054 MATCH CV0($value) 2: 0055, 1: 0055, default: 0059
0055 T15 = QM_ASSIGN string("2, 1")
0056 JMP 0060
0057 T15 = QM_ASSIGN int(1)
0058 JMP 0060
0059 T15 = MATCH_ERROR CV0($value)
0060 ECHO T15
0061 ECHO string("
")
0062 MATCH CV0($value) 1: 0063, default: 0067
0063 T18 = QM_ASSIGN string("1, 1")
0064 JMP 0068
0065 T18 = QM_ASSIGN int(1)
0066 JMP 0068
0067 T18 = MATCH_ERROR CV0($value)
0068 ECHO T18
0069 ECHO string("
")
0070 ECHO string("--EXPECT--
1
2, 1
1, 1
1
2, 1
1, 1
")
0071 RETURN int(1)
$_main:
; (lines=58, args=0, vars=1, tmps=1)
; (after optimizer)
; /tmp/php-src/Zend/tests/match/039.phpt:1-62
0000 ECHO string("--TEST--
Test match with duplicate conditions
--FILE--
")
0001 ASSIGN CV0($value) int(1)
0002 MATCH CV0($value) 1: 0003, 2: 0005, 3: 0007, 4: 0009, 5: 0011, default: 0013
0003 T1 = QM_ASSIGN int(1)
0004 JMP 0014
0005 T1 = QM_ASSIGN int(2)
0006 JMP 0014
0007 T1 = QM_ASSIGN int(3)
0008 JMP 0014
0009 T1 = QM_ASSIGN int(4)
0010 JMP 0014
0011 T1 = QM_ASSIGN int(5)
0012 JMP 0014
0013 T1 = MATCH_ERROR CV0($value)
0014 ECHO T1
0015 ECHO string("
")
0016 MATCH CV0($value) 2: 0017, 1: 0017, 3: 0019, 4: 0021, 5: 0023, default: 0025
0017 T1 = QM_ASSIGN string("2, 1")
0018 JMP 0026
0019 T1 = QM_ASSIGN int(3)
0020 JMP 0026
0021 T1 = QM_ASSIGN int(4)
0022 JMP 0026
0023 T1 = QM_ASSIGN int(5)
0024 JMP 0026
0025 T1 = MATCH_ERROR CV0($value)
0026 ECHO T1
0027 ECHO string("
")
0028 MATCH CV0($value) 1: 0029, 2: 0031, 3: 0033, 4: 0035, 5: 0037, default: 0039
0029 T1 = QM_ASSIGN string("1, 1")
0030 JMP 0040
0031 T1 = QM_ASSIGN string("2, 2")
0032 JMP 0040
0033 T1 = QM_ASSIGN string("3, 3")
0034 JMP 0040
0035 T1 = QM_ASSIGN string("4, 4")
0036 JMP 0040
0037 T1 = QM_ASSIGN string("5, 5")
0038 JMP 0040
0039 T1 = MATCH_ERROR CV0($value)
0040 ECHO T1
0041 ECHO string("
")
0042 MATCH CV0($value) 1: 0043, default: 0044
0043 JMP 0045
0044 T1 = MATCH_ERROR CV0($value)
0045 ECHO T1
0046 ECHO string("
")
0047 MATCH CV0($value) 2: 0048, 1: 0048, default: 0049
0048 JMP 0050
0049 T1 = MATCH_ERROR CV0($value)
0050 ECHO string("2, 1")
0051 ECHO string("
")
0052 MATCH CV0($value) 1: 0053, default: 0054
0053 JMP 0055
0054 T1 = MATCH_ERROR CV0($value)
0055 ECHO string("2, 1")
0056 ECHO string("
--EXPECT--
1
2, 1
1, 1
1
2, 1
1, 1
")
0057 RETURN int(1)
--TEST--
Test match with duplicate conditions
--FILE--
1
2, 1
1, 1
1, 1
2, 1
2, 1
--EXPECT--
1
2, 1
1, 1
1
2, 1
1, 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment