llvm.org GIT mirror llvm / db95389
When emitting a cmp with 0 for a lowered select, mask out the high bits of the value carying the boolean condition, as their contents are undefined. This fixes rdar://10887484. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151310 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 7 years ago
2 changed file(s) with 24 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
28392839 }
28402840 }
28412841 }
2842
2843 // ARM's BooleanContents value is UndefinedBooleanContent. Mask out the
2844 // undefined bits before doing a full-word comparison with zero.
2845 Cond = DAG.getNode(ISD::AND, dl, Cond.getValueType(), Cond,
2846 DAG.getConstant(1, Cond.getValueType()));
28422847
28432848 return DAG.getSelectCC(dl, Cond,
28442849 DAG.getConstant(0, Cond.getValueType()),
0 ; RUN: llc < %s | FileCheck %s
1
2 target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32"
3 target triple = "thumbv7-apple-ios0.0.0"
4
5 ; Codegen should only compare one bit of the loaded value.
6 ; rdar://10887484
7
8 ; CHECK: foo:
9 ; CHECK: ldrb r[[R0:[0-9]+]], [r0]
10 ; CHECK: tst.w r[[R0]], #1
11 define void @foo(i8* %call, double* %p) nounwind {
12 entry:
13 %tmp2 = load i8* %call
14 %tmp3 = trunc i8 %tmp2 to i1
15 %cond = select i1 %tmp3, double 2.000000e+00, double 1.000000e+00
16 store double %cond, double* %p
17 ret void
18 }