-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AArch64][ARM] Avoid some APFloat copies in tablegen patterns. NFC. #114416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-backend-arm @llvm/pr-subscribers-backend-aarch64 Author: Simon Pilgrim (RKSimon) ChangesEither the N->getValueAPF() was being unused or we were failing to make use of it returning a const APFloat& Full diff: https://github.com/llvm/llvm-project/pull/114416.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AArch64/AArch64InstrFormats.td b/llvm/lib/Target/AArch64/AArch64InstrFormats.td
index 837d737b28588c..031d94f5b19c39 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrFormats.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrFormats.td
@@ -1390,14 +1390,12 @@ def arith_uxtx : ComplexPattern<i64, 2, "SelectArithUXTXRegister", []>;
// Floating-point immediate.
def fpimm16XForm : SDNodeXForm<fpimm, [{
- APFloat InVal = N->getValueAPF();
- uint32_t enc = AArch64_AM::getFP16Imm(InVal);
+ uint32_t enc = AArch64_AM::getFP16Imm(N->getValueAPF());
return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
}]>;
def fpimm32XForm : SDNodeXForm<fpimm, [{
- APFloat InVal = N->getValueAPF();
- uint32_t enc = AArch64_AM::getFP32Imm(InVal);
+ uint32_t enc = AArch64_AM::getFP32Imm(N->getValueAPF());
return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
}]>;
@@ -1409,8 +1407,7 @@ def fpimm32SIMDModImmType4XForm : SDNodeXForm<fpimm, [{
}]>;
def fpimm64XForm : SDNodeXForm<fpimm, [{
- APFloat InVal = N->getValueAPF();
- uint32_t enc = AArch64_AM::getFP64Imm(InVal);
+ uint32_t enc = AArch64_AM::getFP64Imm(N->getValueAPF());
return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
}]>;
@@ -1681,7 +1678,6 @@ def simdimmtype10 : Operand<i32>,
return AArch64_AM::isAdvSIMDModImmType10(
Imm.bitcastToAPInt().getZExtValue());
}], SDNodeXForm<fpimm, [{
- APFloat InVal = N->getValueAPF();
uint32_t enc = AArch64_AM::encodeAdvSIMDModImmType10(N->getValueAPF()
.bitcastToAPInt()
.getZExtValue());
diff --git a/llvm/lib/Target/ARM/ARMInstrVFP.td b/llvm/lib/Target/ARM/ARMInstrVFP.td
index 3094a4db2b4d12..46127f972a0ce1 100644
--- a/llvm/lib/Target/ARM/ARMInstrVFP.td
+++ b/llvm/lib/Target/ARM/ARMInstrVFP.td
@@ -46,8 +46,7 @@ def vfp_f16imm : Operand<f16>,
PatLeaf<(f16 fpimm), [{
return ARM_AM::getFP16Imm(N->getValueAPF()) != -1;
}], SDNodeXForm<fpimm, [{
- APFloat InVal = N->getValueAPF();
- uint32_t enc = ARM_AM::getFP16Imm(InVal);
+ uint32_t enc = ARM_AM::getFP16Imm(N->getValueAPF());
return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
}]>> {
let PrintMethod = "printFPImmOperand";
@@ -55,8 +54,7 @@ def vfp_f16imm : Operand<f16>,
}
def vfp_f32f16imm_xform : SDNodeXForm<fpimm, [{
- APFloat InVal = N->getValueAPF();
- uint32_t enc = ARM_AM::getFP32FP16Imm(InVal);
+ uint32_t enc = ARM_AM::getFP32FP16Imm(N->getValueAPF());
return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
}]>;
@@ -65,8 +63,7 @@ def vfp_f32f16imm : PatLeaf<(f32 fpimm), [{
}], vfp_f32f16imm_xform>;
def vfp_f32imm_xform : SDNodeXForm<fpimm, [{
- APFloat InVal = N->getValueAPF();
- uint32_t enc = ARM_AM::getFP32Imm(InVal);
+ uint32_t enc = ARM_AM::getFP32Imm(N->getValueAPF());
return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
}]>;
@@ -88,8 +85,7 @@ def vfp_f32imm : Operand<f32>,
}
def vfp_f64imm_xform : SDNodeXForm<fpimm, [{
- APFloat InVal = N->getValueAPF();
- uint32_t enc = ARM_AM::getFP64Imm(InVal);
+ uint32_t enc = ARM_AM::getFP64Imm(N->getValueAPF());
return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
}]>;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you feel like capitalising Enc that would be an improvement too. Either way LGTM, cheers.
Either the N->getValueAPF() was being unused or we were failing to make use of it returning a const APFloat&
e9f22cb
to
b207bfb
Compare
…lvm#114416) Either the N->getValueAPF() was being unused or we were failing to make use of it returning a const APFloat&
…lvm#114416) Either the N->getValueAPF() was being unused or we were failing to make use of it returning a const APFloat&
Either the N->getValueAPF() was being unused or we were failing to make use of it returning a const APFloat&