[llvm] [Xtensa] Implement Xtensa Floating Point Option. (PR #136086)
Andrei Safronov via llvm-commits
llvm-commits at lists.llvm.org
Thu May 22 04:39:30 PDT 2025
================
@@ -815,6 +936,21 @@ SDValue XtensaTargetLowering::LowerImmediate(SDValue Op,
return Op;
}
+SDValue XtensaTargetLowering::LowerImmediateFP(SDValue Op,
----------------
andreisfr wrote:
Thank you for comment. I've made an experiment with 2 simple tests using i32 and f32 constants. For f32 immediate I used lowering by expansion. And I've got such results:
Integer constant:
"
IR code
%1 = sub i32 %c, 132132
it is translated to
t12: i32 = XtensaISD::PCREL_WRAPPER TargetConstantPool:i32<i32 -132132> 0
t9: i32 = add t2, t12
and then such code generated
t12: i32 = L32R TargetConstantPool:i32<i32 -132132> 0
t9: i32 = ADD t2, t12
This code is correctly loads i32 constant from ConstantPool using L32R instruction
"
Floating point constant:
"
IR code
%c_ = fadd float 0.0, %c
it is translated to
t22: i32 = XtensaISD::PCREL_WRAPPER TargetConstantPool:i32<float 0.000000e+00> 0
t20: f32,ch = load<(load (s32) from constant-pool)> t0, t22, undef:i32
and then such code generated
t22: i32 = L32R TargetConstantPool:i32<float 0.000000e+00> 0
t20: f32,ch = LSI<Mem:(load (s32) from constant-pool)> t22, TargetConstant:i32<0>, t0
This code loads i32 constant from ConstantPool using L32R instruction and then consider this constant as new address to
load another constant using LSI instruction. This is incorrect.
"
So, it seems that if we need to just use expasnsion of the f32 immediate, then we need to make some kind of refactoring of the constant pool implementation.
https://github.com/llvm/llvm-project/pull/136086
More information about the llvm-commits
mailing list