Open llvmbot opened 4 years ago
changed the description
AVR has gained great optimization on 8/16/32-bit shifts.
@llvm/issue-subscribers-backend-msp430
This is unlikely to change in IR (it's a single shift instruction), so it needs a codegen reversal: https://godbolt.org/z/f66h169rd
Here is avr-gcc VS clang, for your original test C code : https://godbolt.org/z/PKc69qdPK
Extended Description
A number of comparisons involving bit tests are converted into shifts by InstCombine and DAGCombine. However, shifts are expensive for most 8 and 16 bit targets with comparatively cheaper selects.
It is desirable that selects are emitted instead of shifts for these targets. The following cases were identified in TargetLowering and DAGCombine and were fixed by:
https://reviews.llvm.org/D69116 https://reviews.llvm.org/D69120 https://reviews.llvm.org/D69326 https://reviews.llvm.org/D70042
Cases in InstCombine remain to be fixed. In llvm-dev it has been suggested that these cases should be fixed by reversing the current canonicalisation. I am showing them in this and following reports:
REPORTED CASE:
Source code:
IR code:
MSP430 Target code:
AVR Target code:
EXPECTED RESULT:
Source code:
Expected IR code:
Expected MSP430 Target code:
Expected AVR Target code: