Commit 2d72fc5
committed
Separate boolean constants from integer constants in egglog optimizer
Introduce BoolConst as a distinct egglog constructor to prevent type
confusion where Gamma(c, x, Const(0)) was incorrectly simplified to
LogAnd(c, x) even in integer contexts. This caused SPIR-V validation
failures (wrong result types on IAdd, FOrdLessThan operand errors)
because OpLogicalAnd requires boolean operands/results.
Key changes:
- Add BoolConst(i64) constructor to datatypes.egg
- Encode OpConstantTrue/False as BoolConst in context.rs
- Parse BoolConst back to OpConstantTrue/False in constants.rs
- Synthesize boolean constants with proper OpTypeBool in mod.rs
- Update Gamma→LogAnd/LogOr rules to match only BoolConst branches
- Update all comparison/logical rules to produce BoolConst results
- Add BoolConst+Const dual matching for interop in logical ops
- Add 14 tests verifying type-safe boolean optimization1 parent 70af80b commit 2d72fc5
File tree
11 files changed
+782
-214
lines changed- rust/spirv-tools-opt/src
- direct
- parse
- egglog_opt
- rules
11 files changed
+782
-214
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
107 | | - | |
| 106 | + | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
702 | 702 | | |
703 | 703 | | |
704 | 704 | | |
705 | | - | |
| 705 | + | |
706 | 706 | | |
707 | 707 | | |
708 | | - | |
| 708 | + | |
709 | 709 | | |
710 | 710 | | |
711 | 711 | | |
| |||
727 | 727 | | |
728 | 728 | | |
729 | 729 | | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
730 | 735 | | |
731 | 736 | | |
732 | 737 | | |
| |||
763 | 768 | | |
764 | 769 | | |
765 | 770 | | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
774 | 781 | | |
775 | 782 | | |
776 | 783 | | |
777 | 784 | | |
778 | 785 | | |
779 | 786 | | |
780 | 787 | | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
781 | 807 | | |
782 | | - | |
783 | | - | |
| 808 | + | |
| 809 | + | |
784 | 810 | | |
785 | 811 | | |
786 | 812 | | |
| |||
798 | 824 | | |
799 | 825 | | |
800 | 826 | | |
801 | | - | |
| 827 | + | |
802 | 828 | | |
803 | 829 | | |
804 | 830 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
67 | 90 | | |
68 | 91 | | |
69 | 92 | | |
| |||
81 | 104 | | |
82 | 105 | | |
83 | 106 | | |
84 | | - | |
85 | | - | |
86 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
87 | 121 | | |
88 | 122 | | |
89 | 123 | | |
90 | 124 | | |
91 | 125 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
98 | 131 | | |
99 | 132 | | |
100 | 133 | | |
101 | 134 | | |
102 | 135 | | |
103 | 136 | | |
104 | 137 | | |
105 | | - | |
| 138 | + | |
106 | 139 | | |
107 | 140 | | |
108 | 141 | | |
109 | 142 | | |
110 | 143 | | |
111 | 144 | | |
| 145 | + | |
112 | 146 | | |
113 | 147 | | |
114 | 148 | | |
| |||
120 | 154 | | |
121 | 155 | | |
122 | 156 | | |
123 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
124 | 178 | | |
125 | 179 | | |
126 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
0 commit comments