[Bug other/61979] New: Why float variable loading twice into the FTU Stack during condition checking ?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61979 Bug ID: 61979 Summary: Why float variable loading twice into the FTU Stack during condition checking ? Product: gcc Version: unknown Status: UNCONFIRMED Severity: minor Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: nasika.srikanth1 at gmail dot com Actually its not a bug. But i identified that float variables are loading twice into the FTU STACK during the condition checking ,that's actually my doubt and i check without loading it again i remove repeated code and getting the same output . But why gcc complier loads the float variable again into the FTU Stack ? For checking the condition it first checks the parity flags(whether NAN ,INF )then it again loads the float variable into FTU stack and check for the zero flag( whether non zero) set or not. But we can directly check the zero flag after checking parity flag with out loading the variable into the FTU stack.
[Bug other/61979] Why float variable loading twice into the FTU Stack during condition checking ?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61979 --- Comment #2 from Srikanth --- Created attachment 33225 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33225&action=edit In this assemble code line number at 22-25 and after 27-30 both are same instructions repeated for conditional checking. In this assemble code line number at 22-25 and after 27-30 both are same instructions repeated for conditional checking. Architecture Intel® Core™ i3-2350M CPU @ 2.30GHz × 4 Sorry its my mistype *not FTU*,its actually FPU Stack means Floating point unit stack I just patch the above code by removing the repeated code file"testcondition.c" .section.rodata .LC2: .string"true" .LC3: .string"false" .text .globlmain .typemain, @function main: .LFB0: .cfi_startproc pushl%ebp .cfi_def_cfa_offset 8 .cfi_offset 5, -8 movl%esp, %ebp .cfi_def_cfa_register 5 andl$-16, %esp subl$32, %esp movl.LC0, %eax movl%eax, 28(%esp) flds28(%esp) fldz fucomip%st(1), %st fstp%st(0) jp.L6 je.L7 .L6: movl$.LC2, (%esp) callprintf jmp.L4 .L7: movl$.LC3, (%esp) callprintf .L4: movl$0, %eax leave .cfi_restore 5 .cfi_def_cfa 4, 4 ret .cfi_endproc .LFE0: .sizemain, .-main .section.rodata .align 4 .LC0: .long1094713344 .ident"GCC: (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1" .section.note.GNU-stack,"",@progbits
[Bug other/61979] Why float variable loading twice into the FTU Stack during condition checking ?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61979 --- Comment #3 from Srikanth --- Comment on attachment 33225 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33225 In this assemble code line number at 22-25 and after 27-30 both are same instructions repeated for conditional checking. > file"testcondition.c" > .section.rodata >.LC2: > .string "true" >.LC3: > .string "false" > .text > .globl main > .type main, @function >main: >.LFB0: > .cfi_startproc > pushl %ebp > .cfi_def_cfa_offset 8 > .cfi_offset 5, -8 > movl%esp, %ebp > .cfi_def_cfa_register 5 > andl$-16, %esp > subl$32, %esp > movl.LC0, %eax > movl%eax, 28(%esp) > flds28(%esp) > fldz > fucomip %st(1), %st > fstp%st(0) > jp .L6 flds28(%esp) fldz fucomip%st(1), %st fstp%st(0) > je .L7 >.L6: > movl$.LC2, (%esp) > callprintf > jmp .L4 >.L7: > movl$.LC3, (%esp) > callprintf >.L4: > movl$0, %eax > leave > .cfi_restore 5 > .cfi_def_cfa 4, 4 > ret > .cfi_endproc >.LFE0: > .size main, .-main > .section.rodata > .align 4 >.LC0: > .long 1094713344 > .ident "GCC: (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1" > .section.note.GNU-stack,"",@progbits
[Bug other/61979] Why float variable loading twice into the FPU Stack during condition checking ?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61979 --- Comment #4 from Srikanth --- In the Above comment-3 assembly code with black color letter are the repeated code i.e storing the float variable twice in FPU stack during conditional checking for parity flag and zero flag. I just patch that one by removing repeated code ,after checking the parity flag i just check the zero flag with out loading it again into the FPU Stack and again compare with zero .
[Bug other/61979] Why float variable loading twice into the FPU Stack during condition checking ?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61979 --- Comment #6 from Srikanth --- int main() { float m=12 m?printf("true"):printf("false"); m=0; m?printf("true"):printf("false"); } and above is the assemble code generated from the source file .. when i seeing the assemble code i just recognize that float variable was loading twice during the conditional checking that's what my doubt ? please tell me why after comparison of parity flag for NAN or not,directly we can check for zero flag for zero or not.But the generated assemble code in #comment 3 ,after comparison of parity flag it again loading the same variable into the FPU stack and again comparing with zero and checking for zero flag and goes to true or false statment why?
[Bug other/61979] Why float variable loading twice into the FPU Stack during condition checking ?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61979 --- Comment #8 from Srikanth --- #include int main() { float m=12; m?printf("true"):printf("false"); m=0; m?printf("true"):printf("false"); return 0; } complied : gcc -S testcase.c -o testcase.s