Skip to content

Begin testing emitted LLVM IR #5073

Closed
Closed
@bstrie

Description

@bstrie
<@pcwalton> strcat: it would be nice to have if foo == true just compile
            into mov eax,foo; test eax,eax; jne ... instead of mov
            eax,whatever; cmp eax,1; jne ...
<@pcwalton> err
<@pcwalton> mov eax,whatever; cmp al,1; jne ...
< strcat> yeah
< strcat> pcwalton: once the range asserts are there, LLVM will compile
          trunc to i1 and then a br to that
< strcat> that's what clang does
< strcat> if you don't put range asserts, it uses an AND for the trunc
<@pcwalton> eww
<@pcwalton> and al,feh I guess?
<@pcwalton> err
<@pcwalton> what am I on
<@pcwalton> and al,1
< strcat> pcwalton: yeah
< strcat> that's one of the things the range asserts will be good for
<@pcwalton> does and set the condition codes?
< strcat> pcwalton: not sure
< strcat> pcwalton: I'm just trying to copy clang as closely as possible
          and not worry about the details :P
< strcat> pcwalton: the LLVM optimizations seem to be very specialized
          for what clang outputs
<@pcwalton> not surprising
< strcat> pcwalton: because even with the range assert, I don't think it
          will avoid the cmp unless you do the trunc and br yourself
< strcat> they do a specific optimization for trunc when ranges are known
          (for clang)

It would be nice to begin testing the emitted LLVM IR to ensure that an expected optimization isn't suddenly deactivated under our noses, especially if LLVM bases its optimizations off of Clang-specific patterns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationA-testsuiteArea: The testsuite used to check the correctness of rustcC-enhancementCategory: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.P-lowLow priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions