Skip to content

Commit 231aa0f

Browse files
committed
AMDGPU: Avoid creating vector extracts if we aren't going to do anything
Try to avoid expensive checks failures from reporting no changes when some dead instructions were introduced.
1 parent 9d9a41e commit 231aa0f

File tree

3 files changed

+290
-325
lines changed

3 files changed

+290
-325
lines changed

llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,19 +2182,18 @@ bool AMDGPUCodeGenPrepareImpl::visitSqrt(IntrinsicInst &Sqrt) {
21822182
isOneOrNegOne(FDiv->getOperand(0)))
21832183
return false;
21842184

2185-
IRBuilder<> Builder(&Sqrt);
21862185
Value *SrcVal = Sqrt.getOperand(0);
2187-
2188-
SmallVector<Value *, 4> SrcVals;
2189-
extractValues(Builder, SrcVals, SrcVal);
2190-
21912186
bool CanTreatAsDAZ = canIgnoreDenormalInput(SrcVal, &Sqrt);
21922187

21932188
// The raw instruction is 1 ulp, but the correction for denormal handling
21942189
// brings it to 2.
21952190
if (!CanTreatAsDAZ && ReqdAccuracy < 2.0f)
21962191
return false;
21972192

2193+
IRBuilder<> Builder(&Sqrt);
2194+
SmallVector<Value *, 4> SrcVals;
2195+
extractValues(Builder, SrcVals, SrcVal);
2196+
21982197
SmallVector<Value *, 4> ResultVals(SrcVals.size());
21992198
for (int I = 0, E = SrcVals.size(); I != E; ++I) {
22002199
if (CanTreatAsDAZ)

0 commit comments

Comments
 (0)