[PATCH] D22747: [InstCombine] try to fold (select C, (sext A), B) into logical ops

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 13:19:48 PDT 2016


arsenm added a subscriber: arsenm.

================
Comment at: lib/Transforms/InstCombine/InstCombineSelect.cpp:918-921
@@ +917,6 @@
+/// logical ops.
+static Instruction *foldSelectExtConst(SelectInst &SI, Instruction *EI,
+                                       Value *C, bool isExtTrueVal,
+                                       bool isSigned,
+                                       InstCombiner::BuilderTy &Builder) {
+  Value *SmallVal = EI->getOperand(0);
----------------
I would swap the parameter order so that the Builder is first and all bools are at the end

================
Comment at: lib/Transforms/InstCombine/InstCombineSelect.cpp:919
@@ +918,3 @@
+static Instruction *foldSelectExtConst(SelectInst &SI, Instruction *EI,
+                                       Value *C, bool isExtTrueVal,
+                                       bool isSigned,
----------------
Make C a ConstantInt and dyn_cast at the call site?

================
Comment at: lib/Transforms/InstCombine/InstCombineSelect.cpp:938-941
@@ +937,6 @@
+
+    if (isSigned)
+      return new SExtInst(Select, SI.getType());
+    else
+      return new ZExtInst(Select, SI.getType());
+  }
----------------
No return after else


https://reviews.llvm.org/D22747





More information about the llvm-commits mailing list