Issue 176119
Summary [x86] LLVM generates movabs + const add instead of single movabs
Labels new issue
Assignees
Reporter foxidokun
    Small reproducible example: https://godbolt.org/z/P1qhh6MdE

For the following IR line:
```llvm
call void inttoptr (i64 -1858894320 to ptr)(i64 -126189214223360, i64 %20, i64 0)
```

clang -O1 (and also -O2 and -O3) generates following code:

```asm
        movabs  rax, -126189214236672
        lea     rdi, [rax + 13312]
        mov     rax, -1858894320
```

It uses a `movabs+lea` combination instead of a single `movabs` instruction.

This occurs inside a single basic block (no jumps to the middle), and as you can see from the third asm line, we do not care about the value of `rax` register after this block. This seems like to be leftover from merging two constants, because both `-126...` and `-126...+13312` are present in this block, however I am not skilled enough to validate this myself.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to