[Bug tree-optimization/83190] missing strlen optimization of the empty string
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83190 Andrew Pinski changed: What|Removed |Added Severity|normal |enhancement
[Bug tree-optimization/83190] missing strlen optimization of the empty string
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83190 Leslie Zhai changed: What|Removed |Added CC||lesliezhai at llvm dot org.cn --- Comment #6 from Leslie Zhai --- (In reply to Martin Sebor from comment #1) > Clang emits optimal code for both functions. Yep! ; ModuleID = 'a.c' source_filename = "a.c" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-redhat-linux" ; Function Attrs: norecurse nounwind readnone uwtable define i32 @f() local_unnamed_addr #0 { ret i32 0 } ; Function Attrs: norecurse nounwind readnone uwtable define i32 @g() local_unnamed_addr #0 { ret i32 0 } attributes #0 = { norecurse nounwind readnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } !llvm.module.flags = !{!0} !llvm.ident = !{!1} !0 = !{i32 1, !"wchar_size", i32 4} !1 = !{!"LLVM China clang version 7.0.0 (g...@github.com:llvm-mirror/clang.git 87bcdaa7f2311f57c35c18efc6cbf5a973a67de7) (g...@github.com:llvm-mirror/llvm.git 4eeea16aaacd6134fd411abcdbab15b630f3302b) (based on LLVM 7.0.0svn)"}
[Bug tree-optimization/83190] missing strlen optimization of the empty string
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83190 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #5 from Jakub Jelinek --- The strlen pass doesn't track of all the string lengths though, that would be prohibitive, at least with the current infrastructure (say char a[100] = {}; just notes that strlen(a) is 0, not that strlen(a + 253) is also 0. Generally, the entry for such a pointer is only created when such pointer is constructed, and at that point it is too late to find the length from the earlier initializer.
[Bug tree-optimization/83190] missing strlen optimization of the empty string
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83190 Richard Biener changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2017-11-28 Ever confirmed|0 |1 --- Comment #4 from Richard Biener --- Confirmed. Probably some off-by-one error.
[Bug tree-optimization/83190] missing strlen optimization of the empty string
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83190 --- Comment #3 from Martin Sebor --- sizeof "012\0" is 5. There are two NULs at the end, one explicit in the initializer string and one implicitly appended by the compiler. That the size is 5 can also be seen in the dump of g(): g () { char a[5]; ... }
[Bug tree-optimization/83190] missing strlen optimization of the empty string
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83190 --- Comment #2 from Andrew Pinski --- Isn't the sizeof a, 4? If so the call to strlen in g is undefined.
[Bug tree-optimization/83190] missing strlen optimization of the empty string
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83190 Martin Sebor changed: What|Removed |Added Keywords||missed-optimization --- Comment #1 from Martin Sebor --- Clang emits optimal code for both functions.