[PATCH] D12377: [NVPTX] Let NVPTX backend detect integer min and max patterns.

Jingyue Wu via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 12:50:03 PDT 2015


jingyue added inline comments.

================
Comment at: lib/Target/NVPTX/NVPTXISelLowering.cpp:4084
@@ +4083,3 @@
+  bool IsMax;
+  switch (cast<CondCodeSDNode>(Cond.getOperand(2))->get()) {
+    case ISD::SETULE:
----------------
These cases require some mental effort to reason about, although I struggled through them :)

It might be better to do this: 
```
SDNode larger; // The larger operand when the condition is true. 
if (op is LT, LE, ULT, or ULE) {
  larger = RHS; 
} else {
  larger = LHS;
}

IsSigned = LT or LE or GT or GE;
IsMax = (Larger == True); // IsMax iff the instruction returns the larger one when the condition is true. 
```


http://reviews.llvm.org/D12377





More information about the llvm-commits mailing list