-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE, insn does not satisfy its constraints #14
Comments
Thanks for the report and reproducer. I can reproduce it. Looking at it. |
AFAICS movsf_internal pattern for xtensa does not have suitable constraints to match loading SF mode constant from a literal pool into an FP register, that's what offending RTL pattern tries to do. I'm not sure how to fix it properly yet. I guess movsf_internal need to be split into patterns with more restrictive predicates that don't allow loading FP registers from memory designated by symbol. Looking into it... |
Hi, is there any update on this? I've also faced this when compiling ulab transform.c:67, movsf_internal, with esp-idf 3.3.5 Thank you. |
Fixes #25 At the -O2 optimization level we get gcc compiler errors which break the build: root@907bbbd0af42:/opt/tflite-micro-micropython/tensorflow# xtensa-esp32-elf-g++ -DNDEBUG -std=c++11 -fstrict-vol atile-bitfields -mlongcalls -nostdlib -fno-rtti -fno-exceptions -fno-threadsafe-statics -Werror -fno-unwind-tables -ffunction-sections -fdata-sections -fmessage-length=0 -DTF_LITE_STATIC_MEMORY -DTF_LITE_DISABLE_X86_NEON -Wsign- compare -Wdouble-promotion -Wshadow -Wunused-variable -Wmissing-field-initializers -Wunused-function -Wswitch -Wvl a -Wall -Wextra -Wstrict-aliasing -Wno-unused-parameter -DESP -Wno-return-type -Wno-strict-aliasing -Wno-ignored-q ualifiers -Wno-return-type -Wno-strict-aliasing -O2 -I. -Itensorflow/lite/micro/tools/make/downloads/gemmlowp -Ite nsorflow/lite/micro/tools/make/downloads/flatbuffers/include -Itensorflow/lite/micro/tools/make/downloads/ruy -Ite nsorflow/lite/micro/tools/make/gen/esp_xtensa-esp32_default/genfiles/ -Itensorflow/lite/micro/tools/make/downloads /kissfft -c tensorflow/lite/micro/kernels/l2_pool_2d.cc -o tensorflow/lite/micro/tools/make/gen/esp_xtensa-esp32_d efault/obj/kernels/tensorflow/lite/micro/kernels/l2_pool_2d.o tensorflow/lite/micro/kernels/l2_pool_2d.cc: In function 'TfLiteStatus tflite::{anonymous}::L2Eval(TfLiteContext*, TfLiteNode*)': tensorflow/lite/micro/kernels/l2_pool_2d.cc:128:1: error: insn does not satisfy its constraints: } ^ (insn 274 18 183 28 (set (reg/v:SF 20 f1 [orig:77 sum_squares ] [77]) (mem/u/c:SF (symbol_ref/u:SI ("*.LC28") [flags 0x2]) [0 S4 A32])) "./tensorflow/lite/kernels/internal/ref erence/pooling.h":169 47 {movsf_internal} (expr_list:REG_EQUAL (const_double:SF 0.0 [0x0.0p+0]) (nil))) during RTL pass: postreload tensorflow/lite/micro/kernels/l2_pool_2d.cc:128:1: internal compiler error: in extract_constrain_insn, at recog.c: 2210 Please submit a full bug report, with preprocessed source if appropriate. See <https://gcc.gnu.org/bugs/> for instructions. Also refer to: jcmvbkbc/gcc-xtensa#14 This failure doesn't happen without the micropython specific build options: -fstrict-volatile-bitfields -mlongcalls -nostdlib and it only happens at the -O2 optimization level. This commit works around the problem by switching to the -O3 optimization level.
Currently on xstormy16 SImode shifts by a single bit require two instructions, and shifts by other non-zero integer immediate constants require five instructions. This patch implements the obvious optimization that shifts by two bits can be done in four instructions, by using two single-bit sequences. Hence, ashift_2 was previously generated as: mov r7,r2 | shl r2,#2 | shl r3,#2 | shr r7,#14 | or r3,r7 ret and with this patch we now generate: shl r2,#1 | rlc r3,#1 | shl r2,#1 | rlc r3,#1 ret 2023-04-23 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * config/stormy16/stormy16.cc (xstormy16_output_shift): Implement SImode shifts by two by performing a single bit SImode shift twice. gcc/testsuite/ChangeLog * gcc.target/xstormy16/shiftsi.c: New test case.
Facing the same issue with ESP-IDF v5.2.1 when trying to compile ThorVG for ESP32-S3. |
@kisvegabor As a workaround, please try adding |
I didn't help in my case, however espressif/esp-idf#11696 (comment) suggests that it's any optimization issue. So I added set_source_files_properties(components/lvgl/src/libts/thorvg/tvgSwImage.cpp PROPERTIES COMPILE_FLAGS "-O0") but it didn't help either. However with -O0 optimization in menuconfig it worked. It seems |
Most likely you are not using the set_source_files_properties command in the same directory where the library containing the file is defined. From CMake manual:
If you give a pointer to the branch where you have tried using set_source_files_properties, I can suggest a way to fix this. |
Ah, I didn't know that. Here is my lvgl forg with ThorVG included: https://github.com/kisvegabor/lvgl_upstream/tree/demo/ebike It's required to add |
Consider constexpr int VAL = 1; struct foo { template <int B> void bar(typename std::conditional<B==VAL, int, float>::type arg) { } }; template void foo::bar<1>(int arg); where we since r11-291 fail to emit the code for the explicit instantiation. That's because cp_walk_subtrees/TYPENAME_TYPE now walks TYPE_CONTEXT ('conditional' here) as well, and in a template finds the B==VAL template argument. VAL is constexpr, which implies const, which in the global scope implies static. constrain_visibility_for_template then makes "struct conditional<(B == VAL), int, float>" non-TREE_PUBLIC. Then symtab_node::needed_p checks TREE_PUBLIC, sees it's 0, and we don't emit any code. I thought the fix would be some ODR-esque check to not consider constexpr variables/fns that are used just for their value. But it turned out to be tricky. For instance, we can't skip determine_visibility in a template; we can't even skip it for value-dep expressions. For example, no-linkage-expr1.C has using P = struct {}*; template <int N> void f(int(*)[((P)0, N)]) {} where ((P)0, N) is value-dep, but N is not relevant here: we have to ferret out the anonymous type. When instantiating, it's already gone. This patch uses decl_constant_var_p. This is to implement (an approximation) [basic.def.odr]#14.5.1 and [basic.def.odr]#5.2. PR c++/110323 gcc/cp/ChangeLog: * decl2.cc (min_vis_expr_r) <case VAR_DECL>: Do nothing for decl_constant_var_p VAR_DECLs. gcc/testsuite/ChangeLog: * g++.dg/template/explicit-instantiation6.C: New test. * g++.dg/template/explicit-instantiation7.C: New test.
@igrr [test.c.282r.ira]
[test.c.284r.postreload]
Of course TARGET_HARD_FLOAT was enabled :) The most impactful change recently is transition from reload to LRA, so IMHO this issue should be resolved with that. |
Hi @jjsuwa-sys3175, thanks for testing and letting me know.
Can you please point me to the commit where this change has occurred? I'll try to build ESP toolchain based on that and try to reproduce. |
24d5e0b See also: GCC Wiki - reload GCC Wiki - LRAIsDefault
Addendum: It would be better to also apply fb7b829. |
@jcmvbkbc The ISA refman (Cadence version) describes an instruction (CONST.S instruction) that assigns some immediate constants to HW FP registers, and requires only the "Floating-Point Coprocessor Option" as configuration option, but which HW version is this instruction available from? If this instruction were available, the above movsf_internal would turn into legitimate and look like this:
then, will result in the assembler output |
It's associated with the "Floating-Point Coprocessor option" (as opposed to the "Floating-Point 2000 Coprocessor option" which doesn't have it). The distinction between these two options is not really represented in the |
I have bumped into this with Arduino 1.8.19 using some 1 year old code (board library 2.??), being recompiled with esp32 board library 3.04. The problem was a function call with 2 x int and 4 x 1-byte parameters -- the code that calls that function gets the "insn does not satisfy constraints" So far I gave copied the code and dropped the function call to work-around the problem. Newer Update: This innocuous piece of code is the problem --- got rid of the float.
|
Recently we ran into this issue on a couple of programs, when compiling code which uses floating point at -O2 optimization level:
test.c (as minimal as i could c-reduce it):
I'm slowly learning my way through the RTL dumps, hoping to find the cause, but wanted to post just in case there is any obvious issue here.
GCC branch I'm using is https://github.com/espressif/gcc/tree/esp_based_on_8_4_0 (a few patches on top of GCC 8.4).
The text was updated successfully, but these errors were encountered: