@@ -964,33 +964,26 @@ class EarlyCSE {
964964 bool overridingStores (const ParseMemoryInst &Earlier,
965965 const ParseMemoryInst &Later);
966966
967- Value *getOrCreateResult (Value *Inst, Type *ExpectedType) const {
968- // TODO: We could insert relevant casts on type mismatch here.
969- if (auto *LI = dyn_cast<LoadInst>(Inst))
970- return LI->getType () == ExpectedType ? LI : nullptr ;
971- if (auto *SI = dyn_cast<StoreInst>(Inst)) {
972- Value *V = SI->getValueOperand ();
973- return V->getType () == ExpectedType ? V : nullptr ;
967+ Value *getOrCreateResult (Instruction *Inst, Type *ExpectedType) const {
968+ // TODO: We could insert relevant casts on type mismatch.
969+ // The load or the store's first operand.
970+ Value *V;
971+ if (auto *II = dyn_cast<IntrinsicInst>(Inst)) {
972+ switch (II->getIntrinsicID ()) {
973+ case Intrinsic::masked_load:
974+ V = II;
975+ break ;
976+ case Intrinsic::masked_store:
977+ V = II->getOperand (0 );
978+ break ;
979+ default :
980+ return TTI.getOrCreateResultFromMemIntrinsic (II, ExpectedType);
981+ }
982+ } else {
983+ V = isa<LoadInst>(Inst) ? Inst : cast<StoreInst>(Inst)->getValueOperand ();
974984 }
975- assert (isa<IntrinsicInst>(Inst) && " Instruction not supported" );
976- auto *II = cast<IntrinsicInst>(Inst);
977- if (isHandledNonTargetIntrinsic (II->getIntrinsicID ()))
978- return getOrCreateResultNonTargetMemIntrinsic (II, ExpectedType);
979- return TTI.getOrCreateResultFromMemIntrinsic (II, ExpectedType);
980- }
981985
982- Value *getOrCreateResultNonTargetMemIntrinsic (IntrinsicInst *II,
983- Type *ExpectedType) const {
984- // TODO: We could insert relevant casts on type mismatch here.
985- switch (II->getIntrinsicID ()) {
986- case Intrinsic::masked_load:
987- return II->getType () == ExpectedType ? II : nullptr ;
988- case Intrinsic::masked_store: {
989- Value *V = II->getOperand (0 );
990- return V->getType () == ExpectedType ? V : nullptr ;
991- }
992- }
993- return nullptr ;
986+ return V->getType () == ExpectedType ? V : nullptr ;
994987 }
995988
996989 // / Return true if the instruction is known to only operate on memory
0 commit comments