[PATCH] D25485: [x86] use 'neg' for negation of bool
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 12 13:23:56 PDT 2016
efriedma added a comment.
Can we do this in SelectionDAGLegalize::ExpandNode instead? I suppose in theory some platform might prefer to lower this using shifts, but I can't think of any off the top of my head.
================
Comment at: lib/Target/X86/X86ISelLowering.cpp:16343
+ if (SrcVT.getScalarSizeInBits() == 1)
+ return DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, DL, VT), N0);
+
----------------
Given "SIGN_EXTEND_INREG(X, i1)", you can transform it to "-(X&1)". But you can't assume the input is zero-extended. I think your patch misbehaves for the following testcase:
```
define void @_Z1fbi(i1 zeroext %a, i32 %b, i8* %p) local_unnamed_addr #0 {
entry:
%conv = trunc i32 %b to i1
%or = or i1 %a, %conv
%s = sext i1 %or to i8
store i8 %s, i8* %p
ret void
}
```
https://reviews.llvm.org/D25485
More information about the llvm-commits
mailing list