[PATCH] D48301: DAG combine "and|or (select c, -1, 0), x" -> "select c, x, 0|-1"

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 20 17:42:32 PDT 2018


rampitec marked 3 inline comments as done.
rampitec added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1908-1911
+    ConstantSDNode *CTN = cast<ConstantSDNode>(CT);
+    ConstantSDNode *CFN = cast<ConstantSDNode>(CF);
+    CanFoldNonConst = (CTN->isNullValue() || CTN->isAllOnesValue()) &&
+                      (CFN->isNullValue() || CFN->isAllOnesValue());
----------------
spatel wrote:
> This should handle vector types. Currently, it will crash:
> 
> 
> ```
> define <4 x i32> @select_or1_vec(i32 %x, <4 x i32> %y) {
>   %c = icmp slt i32 %x, 11
>   %s = select i1 %c, <4 x i32> zeroinitializer, <4 x i32><i32 -1, i32 -1, i32 -1, i32 -1>
>   %a = or <4 x i32> %y, %s
>   ret <4 x i32> %a
> }
> 
> ```
Thank you!


https://reviews.llvm.org/D48301





More information about the llvm-commits mailing list