Closed dplassgit closed 1 year ago
g:proc(arg: int): int { local = arg local++ return local } print "Should be 4: " println g(3)
This fails.
Log:
$ ./scripts/dccrun test/bootstrap/v3/incdec.d --debugopt=2 Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.ConstantPropagationOptimizer visit INFO: Possible replacement of StackLocation local = arg Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.ConstantPropagationOptimizer lambda$visit$0 INFO: REPLACING ip 5: return local: INT (4) with return arg Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.ConstantPropagationOptimizer visit INFO: Possible replacement of TempLocation __temp2 = "Should be 4: " Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.ConstantPropagationOptimizer deleteSource INFO: REPLACING ip 8: __temp2 = \"Should be 4: \" with // nop was: __temp2 = \"Should be 4: \" Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.ConstantPropagationOptimizer visit INFO: REPLACING ip 9: printf("%s", __temp2) with printf("%s", \"Should be 4: \") Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.ConstantPropagationOptimizer visit INFO: Possible replacement of TempLocation __temp3 = 3 Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.ConstantPropagationOptimizer deleteSource INFO: REPLACING ip 10: __temp3 = 3 with // nop was: __temp3 = 3 Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.ConstantPropagationOptimizer visit INFO: REPLACING ip 11: __temp4 = g(__temp3) with __temp4 = g(3) ConstantPropagationOptimizer OPTIMIZED: goto __after_proc_g_1 _g: g(arg: INT) { local: INT (4) = arg local: INT (4)++ return arg end g __after_proc_g_1: // nop was: __temp2 = \"Should be 4: \" printf("%s", \"Should be 4: \") // nop was: __temp3 = 3 __temp4 = g(3) printf("%s\n", __temp4) exit(0) Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.DeadAssignmentOptimizer visit INFO: Killing all unused variables at end of proc: {local: INT (4)=4} Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.DeadAssignmentOptimizer visit INFO: REPLACING ip 4: local: INT (4)++ with // nop was: local: INT (4)++ DeadAssignmentOptimizer OPTIMIZED: goto __after_proc_g_1 _g: g(arg: INT) { local: INT (4) = arg // nop was: local: INT (4)++ return arg end g __after_proc_g_1: // nop was: __temp2 = \"Should be 4: \" printf("%s", \"Should be 4: \") // nop was: __temp3 = 3 __temp4 = g(3) printf("%s\n", __temp4) exit(0) Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.LoopInvariantOptimizer optimize INFO: Loops: [] NopOptimizer OPTIMIZED: goto __after_proc_g_1 _g: g(arg: INT) { local: INT (4) = arg return arg end g __after_proc_g_1: printf("%s", \"Should be 4: \") __temp4 = g(3) printf("%s\n", __temp4) exit(0) Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.ConstantPropagationOptimizer visit INFO: Possible replacement of StackLocation local = arg Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.DeadAssignmentOptimizer visit INFO: Killing all unused variables at end of proc: {local: INT (4)=3} Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.DeadAssignmentOptimizer visit INFO: REPLACING ip 3: local: INT (4) = arg with // nop was: local: INT (4) = arg DeadAssignmentOptimizer OPTIMIZED: goto __after_proc_g_1 _g: g(arg: INT) { // nop was: local: INT (4) = arg return arg end g __after_proc_g_1: printf("%s", \"Should be 4: \") __temp4 = g(3) printf("%s\n", __temp4) exit(0) Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.LoopInvariantOptimizer optimize INFO: Loops: [] NopOptimizer OPTIMIZED: goto __after_proc_g_1 _g: g(arg: INT) { return arg end g __after_proc_g_1: printf("%s", \"Should be 4: \") __temp4 = g(3) printf("%s\n", __temp4) exit(0) Jun 09, 2023 10:02:56 PM com.plasstech.lang.d2.optimize.LoopInvariantOptimizer optimize INFO: Loops: [] ITERATIONS: 5 OPTIMIZED: goto __after_proc_g_1 _g: g(arg: INT) { return arg end g __after_proc_g_1: printf("%s", \"Should be 4: \") __temp4 = g(3) printf("%s\n", __temp4) exit(0) Should be 4: 3
Looks like issue with ConstantPropagationOptimizer not considering inc or dec as an assignment.
This fails.
Log: