[PATCH] D148414: [InstCombine] Expand `foldSelectICmpAndOr` -> `foldSelectICmpAndBinOp` to work for more binops

NAKAMURA Takumi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 25 03:13:43 PDT 2023


chapuni added a comment.

I am using ubuntu-20.04 (amd64) and stage2-clang uses libstdc++ for bootstrapping.

Ubuntu (aarch64) didn't complain. (I don't know why)



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:797
 
-  return Builder.CreateOr(V, Y);
+  return Builder.CreateBinOp(BinOp->getOpcode(), V, Y);
 }
----------------
Would it be right if `BinOp` is not commutative?
I saw a malformed `lshr` in the miscompilation.

`%spec.select = lshr i64 %sub78, %foo` was transformed to `%spec.select = lshr i64 %bar, %sub78`.


================
Comment at: llvm/test/Transforms/InstCombine/select-with-bitwise-ops.ll:1616
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[AND]], 0
+; CHECK-NEXT:    [[XOR:%.*]] = srem i32 [[Y:%.*]], 2
+; CHECK-NEXT:    [[SELECT:%.*]] = select i1 [[CMP]], i32 [[Y]], i32 [[XOR]]
----------------
`XOR` (and `%xor`) is odd here, even if this checks that instructions are not transformed. (ditto in the next test)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148414



More information about the llvm-commits mailing list