@@ -964,33 +964,25 @@ 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+ // The load or the store's first operand.
969+ Value *V;
970+ if (auto *II = dyn_cast<IntrinsicInst>(Inst)) {
971+ switch (II->getIntrinsicID ()) {
972+ case Intrinsic::masked_load:
973+ V = II;
974+ break ;
975+ case Intrinsic::masked_store:
976+ V = II->getOperand (0 );
977+ break ;
978+ default :
979+ return TTI.getOrCreateResultFromMemIntrinsic (II, ExpectedType);
980+ }
981+ } else {
982+ V = isa<LoadInst>(Inst) ? Inst : cast<StoreInst>(Inst)->getValueOperand ();
974983 }
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- }
981984
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 ;
985+ return V->getType () == ExpectedType ? V : nullptr ;
994986 }
995987
996988 // / Return true if the instruction is known to only operate on memory
0 commit comments