[PATCH] D127942: [NewGVN] add context instruction for SimplifyQuery

chenglin.bi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 24 09:38:47 PDT 2022


bcl5980 added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:134
 // the preferred context instruction (if any).
-static const Instruction *safeCxtI(const Value *V, const Instruction *CxtI) {
+static const Instruction *safeCxtI(const Value *V, const Instruction *CxtI,
+                                   bool UseInstrInfo) {
----------------
fhahn wrote:
> it seems it would be slightly simpler to move `safeCxtI` to `SimplifyQuery`?
Just a idea to make sure
How about just set CxtI to nullptr when UseInstrInfo is false? @fhahn @nikic 
```
@@ -115,8 +116,8 @@ struct SimplifyQuery {
                 AssumptionCache *AC = nullptr,
                 const Instruction *CXTI = nullptr, bool UseInstrInfo = true,
                 bool CanUseUndef = true)
-      : DL(DL), TLI(TLI), DT(DT), AC(AC), CxtI(CXTI), IIQ(UseInstrInfo),
-        CanUseUndef(CanUseUndef) {}
+      : DL(DL), TLI(TLI), DT(DT), AC(AC), IIQ(UseInstrInfo),
+        CxtI(UseInstrInfo ? CxtI : nullptr), CanUseUndef(CanUseUndef) {}
```

```
   Query(const DataLayout &DL, AssumptionCache *AC, const Instruction *CxtI,
         const DominatorTree *DT, bool UseInstrInfo,
         OptimizationRemarkEmitter *ORE = nullptr)
-      : DL(DL), AC(AC), CxtI(CxtI), DT(DT), ORE(ORE), IIQ(UseInstrInfo) {}
+      : DL(DL), AC(AC), IIQ(UseInstrInfo), CxtI(UseInstrInfo ? CxtI : nullptr),
+        DT(DT), ORE(ORE) {}
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127942/new/

https://reviews.llvm.org/D127942



More information about the llvm-commits mailing list