Issue |
131129
|
Summary |
[clang] Inconsistent codegen when using -fcomplex-arithmetic=promoted
|
Labels |
clang:codegen
|
Assignees |
|
Reporter |
Maetveis
|
Clang does not consistently generate code when `-fcomplex-arithmetic=promoted` is used:
- Division of a float value by a real value should not cause promotion, but it does
- The divide and assign operator should cause promotion, but it doesn't (uses Smith's algorithm instead)
[See reproducer on compiler explorer](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:2,endLineNumber:16,positionColumn:2,positionLineNumber:16,selectionStartColumn:2,selectionStartLineNumber:16,startColumn:2,startLineNumber:16),source:'float+__complex__+div(float+__complex__+a,+float+__complex__+b)+%7B%0A++++//+Behaves+as+expected%0A++++return+a+/+b%3B%0A%7D%0A%0Afloat+__complex__+div_by_real(float+__complex__+a,+float+b)+%7B%0A++++//+This+promotes+to+double,+but+it+should+not.%0A++++//+Optimizations+will+remove+the+redundant+promotion+/+demotion%0A++++//+but+clang+should+not+generate+it+in+the+first+place%0A++++return+a+/+b%3B%0A%7D%0A%0Afloat+__complex__+div_assign(float+__complex__+a,+float+__complex__+b)+%7B%0A++++//+This+emits+Smith!'s+algorithm+instead+of+promoting+to+double%0A++++return+a+/%3D+b%3B%0A%7D'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:31.1545988258317,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:clang_trunk,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'-O0+-fcomplex-arithmetic%3Dpromoted',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+(trunk)+(Editor+%231)',t:'0'),(h:ir,i:('-fno-discard-value-names':'0',compilerName:'x86-64+clang+(trunk)',demangle-symbols:'0',editorid:1,filter-attributes:'0',filter-comments:'0',filter-debug-info:'0',filter-instruction-metadata:'0',fontScale:14,fontUsePx:'0',j:1,selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),treeid:0,wrap:'1'),l:'5',n:'0',o:'LLVM+IR+Viewer+x86-64+clang+(trunk)+(Editor+%231,+Compiler+%231)',t:'0')),k:50,l:'4',m:78.48238448485434,n:'0',o:'',s:1,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+clang+(trunk)',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+(trunk)+(Compiler+%231)',t:'0')),header:(),l:'4',m:21.51761551514566,n:'0',o:'',s:0,t:'0')),k:68.8454011741683,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs