[llvm] [DAGCombiner] Add some very basic folds for ADDRSPACECAST (PR #127733)
Kai Nacke via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 26 12:15:23 PST 2025
================
@@ -332,9 +332,7 @@ define signext i32 @setlength() {
; CHECK: lgr [[MALLOC:[0-9]+]],3
; CHECK: basr 7,6
; CHECK: lgr [[LENGTH:[0-9]+]],3
-; CHECK: la [[ADDR:[0-9]+]],4([[MALLOC]])
-; CHECK: llgtr [[ADDR]],[[ADDR]]
----------------
redstar wrote:
> the cast is assumed to be reversible (i.e. casting the result back to the original address space should yield the original bit pattern).
Ok, that is a problem. `zext ( x & 0x7FFFFFFF)` is certainly different from `x`. The high bit indicates if the address is code or data, but that information is lost when the pointer is converted to 64 bit. When converting the pointer back to 31 bit, we assume the high bit is zero, because that is what is usually needed. (A set high bit is only required in very rare cases, e.g. changing the return address of a function stored in a stack frame.)
Any suggestion how to get around this issue?
https://github.com/llvm/llvm-project/pull/127733
More information about the llvm-commits
mailing list