|
1 | 1 | /*========================== begin_copyright_notice ============================ |
2 | 2 |
|
3 | | -Copyright (C) 2017-2025 Intel Corporation |
| 3 | +Copyright (C) 2017-2024 Intel Corporation |
4 | 4 |
|
5 | 5 | SPDX-License-Identifier: MIT |
6 | 6 |
|
@@ -183,70 +183,13 @@ static Value *simplifyMulDDQ(BinaryOperator &Mul) { |
183 | 183 | return Result; |
184 | 184 | } |
185 | 185 |
|
186 | | -static inline bool isBitcastFits(BitCastInst *BC) { |
187 | | - return BC->getSrcTy()->isVectorTy() && BC->getDestTy()->isIntegerTy(); |
188 | | -} |
189 | | - |
190 | | -static inline bool isTrunkFits(TruncInst *TC) { |
191 | | - return TC->getSrcTy()->isVectorTy() && |
192 | | - TC->getDestTy()->isVectorTy() && |
193 | | - TC->getDestTy()->getScalarType()->isIntegerTy(1); |
194 | | -} |
195 | | - |
196 | | -static inline bool simplifyBinOp(BinaryOperator *BinOp) { |
197 | | - bool Changed = false; |
198 | | - |
199 | | - auto *Bitcast1 = dyn_cast<BitCastInst>(BinOp->getOperand(0)); |
200 | | - auto *Bitcast2 = dyn_cast<BitCastInst>(BinOp->getOperand(1)); |
201 | | - if (Bitcast1 && Bitcast2 && (Bitcast1->getSrcTy() == Bitcast2->getSrcTy())) { |
202 | | - if (isBitcastFits(Bitcast1) && isBitcastFits(Bitcast2)) { |
203 | | - for (auto *User : BinOp->users()) { |
204 | | - if (auto *BitcastBack = dyn_cast<BitCastInst>(User)) { |
205 | | - if (BitcastBack->getDestTy()->isVectorTy()) { |
206 | | - IRBuilder<> Builder(BinOp); |
207 | | - auto *NewOp = |
208 | | - Builder.CreateBinOp(BinOp->getOpcode(), Bitcast1->getOperand(0), |
209 | | - Bitcast2->getOperand(0)); |
210 | | - BitcastBack->replaceAllUsesWith(NewOp); |
211 | | - Changed = true; |
212 | | - BinOp = cast<BinaryOperator>(NewOp); |
213 | | - break; |
214 | | - } |
215 | | - } |
216 | | - } |
217 | | - } |
218 | | - } |
219 | | - auto *Trunc1 = dyn_cast<TruncInst>(BinOp->getOperand(0)); |
220 | | - auto *Trunc2 = dyn_cast<TruncInst>(BinOp->getOperand(1)); |
221 | | - if (Trunc1 && Trunc2 && (Trunc1->getSrcTy() == Trunc2->getSrcTy())) { |
222 | | - if (isTrunkFits(Trunc1) && isTrunkFits(Trunc2)) { |
223 | | - for (auto *User : BinOp->users()) { |
224 | | - if (auto *ZextInst = dyn_cast<ZExtInst>(User)) { |
225 | | - if (auto *DestVecType = dyn_cast<VectorType>(ZextInst->getDestTy())) { |
226 | | - if (DestVecType->getElementType()->isIntegerTy()) { |
227 | | - IRBuilder<> Builder(BinOp); |
228 | | - auto *NewOp = |
229 | | - Builder.CreateBinOp(BinOp->getOpcode(), Trunc1->getOperand(0), |
230 | | - Trunc2->getOperand(0)); |
231 | | - ZextInst->replaceAllUsesWith(NewOp); |
232 | | - Changed = true; |
233 | | - break; |
234 | | - } |
235 | | - } |
236 | | - } |
237 | | - } |
238 | | - } |
239 | | - } |
240 | | - return Changed; |
241 | | -} |
242 | | - |
243 | 186 | static Value *GenXSimplifyInstruction(llvm::Instruction *Inst) { |
244 | 187 | IGC_ASSERT(Inst); |
245 | 188 | if (!GenXEnablePeepholes) |
246 | 189 | return nullptr; |
247 | | - if (Inst->getOpcode() == Instruction::Mul) |
| 190 | + if (Inst->getOpcode() == Instruction::Mul) { |
248 | 191 | return simplifyMulDDQ(*cast<BinaryOperator>(Inst)); |
249 | | - |
| 192 | + } |
250 | 193 | return nullptr; |
251 | 194 | } |
252 | 195 |
|
@@ -563,8 +506,6 @@ bool GenXSimplify::runOnFunction(Function &F) { |
563 | 506 | Changed |= replaceWithNewValue(*Inst, *V); |
564 | 507 | continue; |
565 | 508 | } |
566 | | - if (auto *BO = dyn_cast<BinaryOperator>(Inst)) |
567 | | - Changed |= simplifyBinOp(BO); |
568 | 509 | } |
569 | 510 | } |
570 | 511 |
|
|
0 commit comments