Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -125,6 +125,11 @@ cl::desc("Limit the number of times for the same StoreNode and RootNode " "to bail out in store merging dependence check")); +static cl::opt EnableReduceLoadOpStoreWidth( + "combiner-reduce-load-op-store-width", cl::Hidden, cl::init(true), + cl::desc("DAG cominber enable reducing the width of load/op/store " + "sequence")); + namespace { class DAGCombiner { @@ -15405,6 +15410,9 @@ /// narrowing the load and store if it would end up being a win for performance /// or code size. SDValue DAGCombiner::ReduceLoadOpStoreWidth(SDNode *N) { + if (!EnableReduceLoadOpStoreWidth) + return SDValue(); + StoreSDNode *ST = cast(N); if (!ST->isSimple()) return SDValue(); Index: llvm/test/CodeGen/X86/clear-bitfield.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/X86/clear-bitfield.ll @@ -0,0 +1,14 @@ +; RUN: llc < %s -mtriple=x86_64-- -combiner-reduce-load-op-store-width=false | FileCheck %s + +%struct.bit_fields = type { i32 } + +; CHECK: andl $-2, (%rdi) +define void @clear_b1(%struct.bit_fields* %ptr) { +entry: + %0 = bitcast %struct.bit_fields* %ptr to i32* + %bf.load = load i32, i32* %0 + %bf.clear = and i32 %bf.load, -2 + store i32 %bf.clear, i32* %0 + ret void +} +