http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54935
Bug #: 54935 Summary: No way to do if converison Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: ysrum...@gmail.com In a process of analyzing of gcc peformance on x86 including vectorization we found out that on spec2006/462.libquantum (e.g.file gates.c, routine quantum_cnot) vectorization of simple loop is not performed since if-conversion has not happened even if we pass explicit option to if-convert store stmt aka "-ftree-loop-if-convert-stores". I can illustrate it on the following simple test-case: extern int a[100], b[100]; void foo(int n) { int i; for (i=1; i<n;i++) { if (a[i] != b[i]) a[i] = b[i] + 1; } } Note that if I insert into loop "a[0] = 0;" stmt if conversion will happen but this is not suitable for the whole benchmark. I also tried to use lto that could detect writable memory access but without any success. I assume that we can detect writable accesses without having unconditional write to that memory but simple through object type specification of a given object. BTW I don't know how array a[] with external declaration must be defined to put in read-only section. Please, also check gcc external definition of "-ftree-loop-if-convert-stores" option that does not match with the following commentary: /* Return true when the memory references of STMT won't trap in the if-converted code. There are two things that we have to check for: - writes to memory occur to writable memory: if-conversion of memory writes transforms the conditional memory writes into unconditional writes, i.e. "if (cond) A[i] = foo" is transformed into "A[i] = cond ? foo : A[i]", and as the write to memory may not be executed at all in the original code, it may be a readonly memory. To check that A is not const-qualified, we check that there exists at least an unconditional write to A in the current function. - reads or writes to memory are valid memory accesses for every iteration. To check that the memory accesses are correctly formed and that we are allowed to read and write in these locations, we check that the memory accesses to be if-converted occur at every iteration unconditionally. */ static bool ifcvt_memrefs_wont_trap (gimple stmt, VEC (data_reference_p, heap) *refs) { return write_memrefs_written_at_least_once (stmt, refs) && memrefs_read_or_written_unconditionally (stmt, refs); }